为什么 Visual Studio 2008 会更改生成的文件中的命名空间字符?
我正在瑞典从事一个 asp.net 3.5 项目,其中一些命名空间包含瑞典字符,例如“å”、“ä”和“ö”。 当构建项目并生成设计文件时,Visual Studio 将这些字符替换为其他一些奇怪的字符。仅当字符出现在命名空间或类名中时才会发生这种情况。如果字段或变量包含瑞典字符,则一切正常。为了澄清,当命名空间和/或控件包含瑞典字符时,设计文件中会出现奇怪的字符。 有谁知道为什么会发生这种情况,以及是否有解决该问题的方法,而无需更改名称空间的名称?
真挚地, 弗雷德里克
I am working on a asp.net 3.5 project in sweden, where some of the namespaces include swedish characters, such as 'å', 'ä' and 'ö'.
When building the project and generating the design-file, visual studio replaces these characters with some other strange characters. This only happens when the characters occur in a namespace or class name. If a field or variable contain a swedish character, everything works fine. To clarify, the strange character occur in the design file when a namespace and/or control contain swedish characters.
Does anyone know why this happens and if there is a solution for the problem that doesn't mean changing the names of the namespaces?
Sincerely,
Fredrik
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当您在源代码中放入国际字符时,Visual Studio 会自动更改文件的编码,以便它可以处理这些字符。显然它不会自动更改自动生成的文件的编码。
您没有提到实际的问题是什么,即这是否会导致代码无法编译,或者命名空间的更改是否只是带来不便。如果代码仍然有效,那么它可能只是设计文件显示方式的问题,并不需要真正修复。
如果代码无法编译,您可以尝试将设计文件保存为 UTF-8,并查看重新生成代码时是否保留编码。
如果这不起作用,除了更改名称空间之外,我看不到任何其他解决方案。
When you put international characters in the source code, Visual Studio automatically changes the encoding of the file so that it can handle the characters. Obviously it doesn't change the encoding automatically for the auto generated file.
You don't mention what the actual problem is, i.e. whether this keeps the code from compiliing or if it's just an inconvenience that the namespaces change. If the code is still working, then it's probably just a problem with how the design file is displayed, and doesn't really have to be fixed.
If the code doesn't compile, you could try saving the design file as UTF-8, and see if it retains the encoding when the code is regenerated.
If that doesn't work, I don't see any other solution than changing the namespaces.
你用Resharper吗?我听说 Resharper 在某些情况下会更改文件编码。
Do you use Resharper? I heard of Resharper changing file encoding in some cases.