javascripthtmlangularjs

Javascript Being Converted to Chinese Characters


I have this simple angular app using angular 1.6.1.

index.html

<!DOCTYPE html>
<html ng-app="App">

<head>
    <title>Test</title>

    <script src="bower_components/angular/angular.js"></script>
    <script src="app/app.js"></script>
</head>

<body>
    <div>
        <home></home>
    </div>
</body>
</html>

app.js

(function() {

    'use strict';

    var app = angular.module('App', []);

    app.component('home', {
            template: '<h1>{{$ctrl.head}}</h1><ul><li>1</li><li>2</li></ul>',
            controller: function() {
                var vm = this;

                this.head = "ONE";
            }
        });
})();

This will load OK and display corretly in IE11, but fails to load on Chrome( 55.0.2883.87 beta (64-bit) or FF (51.0b13 (32-bit) and I have absolutly no idea why ....

whne I click on the app.js in Sources tab in Chrom Dev Tool the source is in wierd chineese like characters, but looking at source via Notepad++, all looks OK ... ?!?!

here is a screenshot of devconsole on chrome

enter image description here

I can see the same issue for every JS file I add to index.html. I didn't change any locale settings aor anything else in the browsers ot my PC ...

I have no idea why is this happening. Anyone seen anything like this?


Solution

  • all files were created in command line by typing

    echo "" >> app.js
    

    and this has set encoding to UCS-2 LE BOM as displayed in Notepad++, and for some unknow reason Chrome and firefox could not read the files correctly ...

    enter image description here

    So converting file to UTF-8-BOM in Notepad++ (Menu -> Encoding -> Convert to UTF-8-BOM) file was read fine and all worked...

    I would be still interested on why old IE managed to read the site OK, but more modern browsers failed ...