AngularJS编码德语变音符 [英] AngularJS encoding german umlauts

查看:53
本文介绍了AngularJS编码德语变音符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将我的角度应用程序嵌入到sharepoint内容编辑器Webpart中。
应用程序与共享点站点不在同一目录中。它托管在单独的网络服务器上。
共享点站点包含必要的元标记

i've embedded my angular application inside a sharepoint content editor webpart. the app is not in the same directory as the sharepoint site. it's hosted on a separate webserver. the sharepoint site contains the necessary meta tags

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

我也按如下方式引用我的脚本:

i also reference my script as follows:

<script type="text/javascript" charset="utf-8" src='http://server/app.js'></script>

角度index.html没有头和身标记,因为它只是嵌入在另一页中(尽管我用额外的头部(+ meta)和身体标记对其进行了测试-无效)。

angular index.html doesn't have a head and body tag because it's just embedded inside the other page (although i tested it with extra head (+meta) and body tag - did't work).

如果我写了一些纯文本('Äpfelsindgroßartig')在我的index.html中,它可以正确显示。如果我像这样在index.html中放跨度:

if i write some plain text ('Äpfel sind großartig') inside my index.html it is displayed correctly. if i put a span inside index.html like that:

<span>{{myText}}</span>

并在控制器中设置 myText

and set 'myText' inside my controller

$scope.myText = 'Äpfel sind großartig'

我只是收到奇怪的文字(德语字符弄乱了)。
甚至是控制台文本

i just get weird text (german characters messed up). even the console text

console.log('Äpfel...')

搞砸了。

我也在使用kendo ui控件,例如他们的网格。德国列名称(例如Geändertam)也被弄乱了。

i'm also using kendo ui controls like their grid. german column names (like 'Geändert am') are messed up there, too.

您知道如何解决该问题吗?

do you have any idea how to fix that?

非常感谢您!

推荐答案

我必须设置在Visual Studio中将javascript和html 文件编码为utf-8。

i had to set the encoding of the javascript and html files to utf-8 in visual studio.

通过将现有文件中的代码减少到最小的angularjs应用程序,并将其与运行完全相同代码的新创建文件进行比较,我发现了这一点。新创建的文件正确显示了字符,而内部带有相同代码的旧文件则没有。因此文件本身一定有问题。使用Visual Studio更改文件编码的方式是这样的:

i figured that out by reducing the code in my existing files to a minimal angularjs application and comparing that to newly created files running the exact same code. the newly created files displayed the characters correctly, whereas the old files with the same code inside did not. so it had to be something wrong with the files itself. changing the file encoding with visual studio worked like this:


  • 在Visual Studio中打开文件

  • FILE>高级保存选项...

  • 编码> Unicode(带签名的UTF-8)-代码页65001

  • 确定

  • open the file in Visual Studio
  • FILE > "Advanced Save Options..."
  • Encoding > "Unicode (UTF-8 with signature) - Codepage 65001"
  • OK

这篇关于AngularJS编码德语变音符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆