index.html to the main file and correctly encodes special characters (...">

Angular2 - How to code UTF-8 in components

I added <meta charset="UTF-8">index.html to the main file and correctly encodes special characters (for example, é, ç or à) that are entered inside this file, without using ascii encoding, for example &eacute;.

However, component templates seem to lose the encoding of special characters that are not entered in ascii.

I'm really not stuck as there is a workaround for ascii, but I'm curious about the logic that seems to prevent character encoding in component templates.

+4
source share
2 answers

As Mark and Plunker note, the problem does not occur in the dev source directory.

A character encoding problem appeared when the "gulping" html files in the / dist directory.

, gulp -utf8-convert https://www.npmjs.com/package/gulp-utf8-convert

var gulp = require('gulp');
var utf8Convert = require('gulp-utf8-convert');

gulp.task('copy-html', function() {
return gulp.src('src/**/*.html')
    .pipe(utf8Convert())
    .pipe(gulp.dest('www'));
});
+3

, .ts UTF-8.

for file in ./**/*.ts; do  iconv -f us-ascii -t utf-16 "$file" -o "${file}"; done
for file in ./**/*.ts; do  iconv -f utf-16le -t utf-8 "$file" -o "${file}"; done
+1

All Articles