为什么不允许Visual Studio(Xamarin)中的Android资产文件带有重音符号? [英] Why are Android Asset files in Visual Studio (Xamarin) not allowed to have accents?
问题描述
我有一个Visual Studio(Xamarin,Android)项目,该文件的名称中带有重音符号:
I have a Visual Studio (Xamarin, Android) project with a file which has an accent character in the name:
diário.png
此文件位于Assets文件夹中,并标记为Android Asset.
This file is in the Assets folder, and marked as an Android Asset.
不幸的是,在构建项目时,出现编译错误:
Unfortunately when I build the project, I get a compile error:
C:\Users\vchel\Documents\FlatRedBallProjects\AndroidSpecialCharacter\AndroidSpecialCharacter\obj\Debug\assets\content\gumproject\dißrio.png : error : Invalid filename. Unable to add.
C:\Users\vchel\Documents\FlatRedBallProjects\AndroidSpecialCharacter\AndroidSpecialCharacter\obj\Debug\assets\content\gumproject\dißrio.png : error : Invalid filename. Unable to add.
请注意,该文件在我的项目中是diário.png,但错误将其引用为dißrio.png.
Notice that the file is diário.png in my project, but the error references it as dißrio.png.
如果我将文件重命名为diario.png(字母a上方无重音),则项目构建良好.
If I rename the file to diario.png (no accent above the letter a) the project builds fine.
我知道我可以通过不使用文件中的重音符来解决此问题,但这似乎是一个奇怪的限制.这是一个已知的问题?除了避免在文件名中使用重音符号之外,还有其他解决方法吗?
I know I could work around this by not using accent characters in my file but this seems like a strange restriction. Is this a known issue? Is there another way to solve this other than avoiding using accents in file names?
推荐答案
资产命名限制一直绑定到Android API 1
,相关的构建工具和.apk
打包(并且与Xamarin无关)框架).
Asset naming restrictions are bound all the way back to Android API 1
, the related build tools and .apk
packaging (and has nothing to due with the Xamarin framework).
-
用于命名资源的有效字符为[a-z,_,0–9]
Valid characters for naming resources are [a-z, _, 0–9]
- 小写字母,数字和下划线
使用下划线(_
)作为资产中单词"之间的多名称分隔符
Use an underscore (_
) as a multi-name separator between "words" in your assets
- 连字符,不能使用句点
第一个字母可以是_或小写字母
The first letter can be either _ or a small case character
- 数字不能作为第一个字符
注意:Android Developer网站上曾经有关于这些限制的说明,但是由于它们剥夺了大多数用于构建工具的文档,我再也找不到它们了
Note: There used to be notes on these restrictions on the Android Developer site, but I can no longer find them as they stripped out most docs for the build tools
这篇关于为什么不允许Visual Studio(Xamarin)中的Android资产文件带有重音符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!