I'm using MVC ScriptManager to Compress and concatenate all my .js files. It works very well, except that if a *.js has a special character such as "á, à" it turns to "Ã!".
I'm trying to change the source code but with no success so far.
Does anyone have an idea what this could be?
Thanks!!
You can write them like \u00f1. Here you can look up the special characters: http://www.fileformat.info/info/unicode/char/search.htm
It looks like the source file encoding is ANSI, and the output is encoded as UTF-8.
In VS use the Advanced Save Options from the File menu to save the original .js file as UTF-8 with a signature (code page 65001).
I make a point of saving all text-type files (.cs, .js, .css, etc.) as UTF-8 to avoid any of these issues later on.
Related
I am trying to run a script through HTML but I am having some problems. I searched online and found how to do so, however the issue is that even if I correctly type the path of the .js file, it seems to add some strange characters before it.
This is in index.html
<script type="text/javascript" src="fractalTest/fractalTest.js"></script>
I expected this to work but when I open index.html in google chrome and inspect then look under the elements tab, this "â©fractalTest/fractalTest.js" is replacing "fractalTest/fractalTest.js" in the path of the file. I believe this is whats causing the error but I do not know how to fix it!
...it seems to add some strange characters before it.
That usually means that the file is saved with a byte-order mark (BOM) of some kind, but isn't being sent with the correct charset for that byte-order mark.
Be sure that the server is configured to serve the files with a specific encoding (UTF-8 is a good choice), and that you save the files using that encoding (in your text editor, etc.). It's also usually best not to include a BOM on UTF-8 files (although it's valid, some tools don't handle it well).
Side note: No need for the type attribute. The default is JavaScript.
I'm very new to angular 2, so I'm trying to make this work: https://angular.io/guide/quickstart
The problem which I have really confuses me. All JS files, which I get as a response, have strange encoding - basically, I see a bunch of hieroglyphs. Non-js files (html and css) are ok. Please see below, html is ok. Js - totally not.
Do you guys have any idea, what can it be? Computer culture is not Chinese or Japanese, just in case.
You can use notepad++ or any html editor with encode options available to change the page encoding:
Open your file with Notepad++
Go to "Encoding" menu option in main menu
Select "Convert to UTF-8-BOM"
check if the page display correctly
This can be related to your js files encoding on your editor.
I use the less compiler with node.js and I know there is an issue with the files encoded in UTF-8 with BOM. For this, this workaround works great:
data = data.replace(/^\uFEFF/, ''); // Strip potential BOM
However, when importing files, using #import statements still gives a syntax error on first line. Are there any way to work around this as well?
The BOM will be stripped in the next version of less.js - 1.3.1. You can also try it out on the github source pages.
https://github.com/cloudhead/less.js/commit/6696368eb351824f33dc0aac67143d8ea80a085a
A BOM in an UTF-8 file makes no sense.
You should fix the source files as many other tools will (rightly) have problems with this BOM. All serious editors are able to write UTF-8 files without BOM.
If you must receive and handle such files, you should automaticaly fix them using for example (operating on a work copy if needed) :
awk '{if(NR==1)sub(/^\xef\xbb\xbf/,"");print}' INFILE > OUTFILE
(taken from Using awk to remove the Byte-order mark)
In an external javascript file I have a function that is used to append text to table cells (within the HTML doc that the javascript file is added to), text that can sometimes have Finnish characters (such as ä). That text is passed as an argument to my function:
content += addTableField(XML, 'Käyttötarkoitus', 'purpose', 255);
The problem is that diacritics such as "ä" get converted to some other bogus characters, such as "�". I see this when viewing the HTML doc in a browser. This is obviously not desirable, and is quite strange as well since the character encoding for the HTML doc is UTF-8.
How can I solve this problem?
Thanks in advance for helping out!
The file that contains content += addTableField(XML, 'Käyttötarkoitus', 'purpose', 255); is not saved in UTF-8 encoding.
I don't know what editor you are using but you can find it in settings or in the save dialog.
Example:
If you can't get this to work you could always write out the literal code points in javascript:
content += addTableField(XML, 'K\u00E4ytt\u00f6tarkoitus', 'purpose', 255);
credit: triplee
To check out the character encoding announced by a server, you can use Firebug (in the Info menu, there’s a command for viewing HTTP headers). Alternatively, you can use online services like Web-Sniffer.
If the headers for the external .js file specify a charset parameter, you need to use that encoding, unless you can change the relevant server settings (perhaps a .htaccess file).
If they lack a charset parameter, you can specify the encoding in the script element, e.g. <script src="foo.js" charset="utf-8">.
The declared encoding should of course match the actual encoding, which you can normally select when you save a file (using “Save As” command if needed).
The character encoding of the HTML file / doc does not matter any external ressource.
You will need to deliver the script file with UTF8 character encoding. If it was saved as such, your server config is bogus.
I've just installed nXhtml by downloading their zip file, extracting the archive into my home directory and adding (load "/home/spinlock/nxhtml/autostart.el") to my .emacs file. My problem is that when I try to edit a .js.erb file, I'm getting the error:
(No javascript-mode/eruby-javascript)
and I'm not getting the syntax highlighting that I'd expect (for instance, comments are the same color as javascript code). However, when I move the cursor inside a Ruby section of this file, that notice changes to:
(Ruby/eruby-javascript)
which I take as a good sign plus it does look like I've got the proper Ruby syntax highlighting in this part of the buffer (e.g. comments are show in red font).
I assume that I need to add a configuration file that tells emacs how to manage javascript-mode but I have no clue how to do this. Any help would be greatly appreciated.
Thanks!