我正在尝试使用unicode系统来呈现正确的日语值char:
'ァ' = ァ
所以,当我$scope.name = 'ァ';
时,日语字符ァ
没有呈现。
我应该怎么做正则表达式?像这样:
#Match Katakana
regex = u'[\u30A0-\u30FF]+' # == u'[ァ-ヾ]+'
答案 0 :(得分:1)
您好我实际上使用'ngsanitize'来解决问题 这是样本
(function(angular) {
'use strict';
angular.module('bindHtmlExample', ['ngSanitize'])
.controller('ExampleController', ['$scope',
function($scope) {
$scope.myHTML = 'I am an ザ string with '
}
]);
})(window.angular);
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example - example-example61-production</title>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.8/angular-sanitize.js"></script>
</head>
<body ng-app="bindHtmlExample">
<div ng-controller="ExampleController">
<p ng-bind-html="myHTML"></p>
</body>
</html>
答案 1 :(得分:0)
符号ァ
是HTML和XML字符引用。在JavaScript中,它只是一串八个Ascii字符,没有特殊含义。
相反,使用字符本身,如@zeroflagL在评论中建议:$scope.name = 'ァ'
,前提是该文件实际上是UTF-8编码并且正确声明了此编码。如果这不可行,请使用 JavaScript 表示法通过其Unicode编号引用字符:$scope.name = '\u30A1'
。这与字符编码无关。