Get wrong characters jquery.min.js - javascript

I'm using with the file: jquery.fileuploader.min. when I change the string in the file from English text to Hebrew it returns wrong encoding.
I changed to:
text:{uploadButton:"עיין",cancelButton:"Cancel",......
instead of:
text:{uploadButton:"Upload A File",cancelButton:"Cancel",......
Then I get in the Html button: "����" instead of "עיין".
I have in the body a meta tag of Enciding:
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
So I don't know why it happens.

Like adeneo wrote, I opened the jquery.fileuploader.min sheet in Notepad and saved it to utf-8 unicode instead of ansi

Related

Jquery tag input adding some character

I am working with jquery tag input but when I create some tag, the tag automatically include some random character.
Below is the screenshot of the tag input box
Link of image
I don't know how to get rid of it.. I searched on google they give me solution to add some meta tag and I also added some meta like this
<meta charset="UTF-8">
this is the plugin Link which i am using
this is the html code
<input id="expert_tags" name="spl_tags" type="text" class="form-control tags" value=""/>
this is javascript code
$('#expert_tags').tagsInput({});
thats it only that much of code for tag input
Maybe use the following meta tag:
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
If you are getting the tags via ajax you should check if the header is set on the server side. In PHP it would look something like this:
header('Content-Type: text/html; charset=utf-8');

escape vs encodeURIComponent [duplicate]

I thought values entered in forms are properly encoded by browsers.
But this simple test file "test_get_vs_encodeuri.html" shows it's not true:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title></title>
</head><body>
<form id="test" action="test_get_vs_encodeuri.html" method="GET" onsubmit="alert(encodeURIComponent(this.one.value));">
<input name="one" type="text" value="Euro-€">
<input type="submit" value="SUBMIT">
</form>
</body></html>
When hitting submit button:
encodeURICompenent encodes input value into "Euro-%E2%82%AC"
while browser into the GET query writes only a simple "Euro-%80"
Could someone explain?
How do i encode everything in the same way of the borwser's FORM (windows-1252) using Javascript??? (escape function does not work, encodeURIComponent does not work either)?
Or is encodeURIComponent doing unnecessary conversions?
This is a character encoding issue. Your document is using the charset Windows-1252 where the € is at position 128 that is encoded with Windows-1252 as 0x80. But encodeURICompenent is expecting the input to be UTF-8, thus using Unicode’s charset where the € is at position 8364 (PDF) that is encoded with UTF-8 0xE282AC.
A solution would be to use UTF-8 for your document as well. Or you write a mapping to convert UTF-8 encoded strings to Windows-1252.
I think the root of the problem is character encodings. If I mess around with charset in the meta tag and save the file with different encodings I can get the page to render in the browser like this:
(source: boogdesign.com)
That € looks a lot like what you're getting from encodeURIComponent. However I could find no combination of encodings which made any difference to what encodeURIComponent was returning. I can make a difference to what the GET query returns. This is your original page, submitting gives an URL like:
test-get-vs-encodeuri.html?one=Euro-%80
This is a UTF-8 version of the page, submitting gives an URL that looks like this (in Firefox):
http://www.boogdesign.com/examples/encode/test-get-vs-encodeuri-utf8.html?one=Euro-€
But if I copy and paste it I get:
http://www.boogdesign.com/examples/encode/test-get-vs-encodeuri-utf8.html?one=Euro-%E2%82%AC
So it looks like if the page is UTF-8 then the GET and encodeURIComponent match.

How to print special characters with jquery?

I am designing web page in slovak language. To be able to use meantioned language special characters such as á or ž, I am using this html code:
<html lang="sk">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
Now it works as expected but only when I hard code that kind of text into html file.
As soon as I use jquery to print them it breaks down and those characters are not correctly shown.
$("#myDiv").html("áž");
Am I supposed to specify something in jquery or is there another way to overcome this problem?
You can pass the numeric entity for that character into the html() function to achieve that,
Try a sample,
$('body').html('Ξ');
DEMO
I think you may be use some tricks here
Try this
$("#myDiv").html($("<div>").html("áž").text());
Or simply try this
$("#myDiv").text("áž");
It is quite Easy you can do the following
Use any special Character u want
$("#mydiv").text("*&^&*^*&^*");
Here is the Demo

Funky Character getting generated with Javascript?

For some reason this character is getting generated in my HTML email when it is being sent: –. I have tried replacing it with nothing in my PHP using preg_replace('/–/', '', $var), but that is not working. For some reason when I get an email containing HTML this character shows up. I am guessing it is generated from this JavaScript in my code somehow:
$('.comments0').click(function(){
$('.comments').val($('.comments').val() + 'Our warranties are:\nNew – 1 year\nRemanufactured - 6 months\nRepair - 6 months');
});
If it is not being generated with JavaScript, I am not sure how this character keeps getting created in the middle of my HTML. It gets generated right after New, just like this: New – 1 Year. I have no idea why this character is coming up randomly like this.
By the way, here is the HTML directly related to that JavaScript:
<form action="?AddToQuote" method="POST" id="myForm" name="myForm">
<input type="checkbox" name="comments[0]" class="comments0" id="comments0" /><label>6 Months Warranty</label>
<textarea cols="75" rows="6" name="comments" class="comments" id="comments"><?php if(isset($_SESSION['comments'])) { echo $_SESSION['comments']; } ?></textarea>
</form>
Apparently the characters in your message were copied/pasted from somewhere else. If you delete them and manually retype directly in the JS source that should do the trick.
This is an en dash:
New – 1 year
If you don’t serve the script with the same encoding as it was written in, there will be errors. So make sure it’s saved as UTF-8 and serve it as UTF-8. If the JavaScript is part of your HTML, add this at the top of the <head> (HTML5):
<meta charset="utf-8">
You can test it:
$ echo '–' > test.html
$ firefox test.html
(– shows up in a browser)
Be sure that your text editor / IDE is set to save files as UTF-8 with NO BOM.
Also, be sure you are using <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> in your page <head> and setting your emails up as UTF-8.

Foreign characters when loading external html code

I have the following javascript, loading my menu on all of my pages
<script type = "text/javascript">
$(document).ready(function () {
$("#menudiv").load("menu.html");
});
</script>
I havent included the menu as it is a completely standard list, formatted to look like it does. One of the menu option contains the character "å", how can I make my page display this character correctly?
This usually happens when the server doesn't set the encoding of menu.html correctly. Make sure the correct encoding is in the headers. (see this document) Especially, make sure that the Content-Type header is correct and that you have a <meta charset="..."> element in menu.html
The encoding of the existing page doesn't matter at all! Whenever you download something, the browser will look for the encoding of the new data, convert that to Unicode and only then, merge the new data with what it already has.
add this HTML Meta tag in your page:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Or in HTML5 Way :
<meta charset="iso-8859-1">
Add the following meta tag to the head of your HTML document:
<meta charset="iso-8859-1">
Use the HTML entity code for displaying this and other ISO characters:
å or å
More information on HTML entities from w3: http://www.w3schools.com/tags/ref_entities.asp

Categories