外国文化XML文本解析 [英] foreign culture XML text parsing

查看:161
本文介绍了外国文化XML文本解析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经发布了一个Windows Phone应用程序。从那时起,BugSense报告了一个在国外造成一些崩溃的问题:

I have released a windows phone app a while back. Since then, BugSense reported a problem that is causing some crashes in foreign countries:


System.ArgumentException - 字符'İ'(0x0130)在此SpriteFont中不可用
。如果适用,请调整字体的开始和结束
CharacterRegions以包含此字符。参数名称:字符

System.ArgumentException - The character 'İ' (0x0130) is not available in this SpriteFont. If applicable, adjust the font's start and end CharacterRegions to include this character. Parameter name: character

这里是堆栈跟踪:

$


Microsoft.Xna.Framework.Graphics.SpriteFont.GetIndexForCharacter(Char
字符)
Microsoft.Xna.Framework.Graphics.SpriteFont.InternalMeasure(StringProxy&
文本)
Microsoft.Xna.Framework.Graphics.SpriteFont.MeasureString(String text)
在GlobalEngine.Visual.TextBase.CalculateSpriteOrigin(对象发件人,
EventArgs e)在系统.EventHandler.Invoke(Object sender,EventArgs e)
在GlobalEngine.Visual.TextBase.set_FormattedText(String value)at
GlobalEngine.Visual.TextLabel.set_Text(String value)at
FourWordsLibrary。 GameUtils.Letter..ctor(Char letter,AssetManager
assetManager,SpriteBatch spriteBatch,Single width)at
FourWordsLibrary.GameUtils.Word..ctor(String orderedWord,String
shuffledWord,AssetManager assetManager, SpriteBatch spriteBatch,
InputManager inputManager,Single letterWidth)
FourWordsLibrary.GameUtils.Word..ctor(String orderedWord,String
shuffledWord,AssetManager assetManager,SpriteBatch spriteBatch,
InputManager inputManager)at
FourWordsLibrary.Controllers .GameControl.StatePlay.SetupNextLevel()在
FourWordsLibrary.Controllers.GameControl.StatePlay.Activate(Object
obj)在GlobalEngine.Base.StateManager 1.SetState(T state,Object obj)
在GlobalEngine.Base.StateManager
1.SetState(T状态)在
FourWordsLibrary.Controllers.GameControl.SetPack(PackManager
packManager)在FourWords.Screens .GameScreen..ctor(引擎引擎,
对象obj)

at Microsoft.Xna.Framework.Graphics.SpriteFont.GetIndexForCharacter(Char character) at Microsoft.Xna.Framework.Graphics.SpriteFont.InternalMeasure(StringProxy& text) at Microsoft.Xna.Framework.Graphics.SpriteFont.MeasureString(String text) at GlobalEngine.Visual.TextBase.CalculateSpriteOrigin(Object sender, EventArgs e) at System.EventHandler.Invoke(Object sender, EventArgs e) at GlobalEngine.Visual.TextBase.set_FormattedText(String value) at GlobalEngine.Visual.TextLabel.set_Text(String value) at FourWordsLibrary.GameUtils.Letter..ctor(Char letter, AssetManager assetManager, SpriteBatch spriteBatch, Single width) at FourWordsLibrary.GameUtils.Word..ctor(String orderedWord, String shuffledWord, AssetManager assetManager, SpriteBatch spriteBatch, InputManager inputManager, Single letterWidth) at FourWordsLibrary.GameUtils.Word..ctor(String orderedWord, String shuffledWord, AssetManager assetManager, SpriteBatch spriteBatch, InputManager inputManager) at FourWordsLibrary.Controllers.GameControl.StatePlay.SetupNextLevel() at FourWordsLibrary.Controllers.GameControl.StatePlay.Activate(Object obj) at GlobalEngine.Base.StateManager1.SetState(T state, Object obj) at GlobalEngine.Base.StateManager1.SetState(T state) at FourWordsLibrary.Controllers.GameControl.SetPack(PackManager packManager) at FourWords.Screens.GameScreen..ctor(Engine engine, Object obj)

我的应用程序是一个单词游戏,我检索来自XML文件的每个级别的单词。所以我怀疑XmlReader正在读取该文件,它使用外部文化,导致检索拉丁字母,然后应用程序在使用严格英文的sprite字体绘制字母时崩溃。
我尝试寻找一种方法来指示XmlReader使用InvariantCulture读取,类似于.toString()方法中找到的,但没有找到任何。任何想法如何解决这个问题?

My app is a word game, and I retrieve the words for each level from an XML file. So I suspect that as the XmlReader is reading the file, it does so using a foreign culture which results in with a Latin letter being retrieved, then the app crashes when it tries to draw the letter using a strictly English sprite-font. I tried looking for a way to instruct the XmlReader to read using InvariantCulture, similar to that found in the .toString() method, but haven't found any. Any ideas how to solve this issue?

推荐答案

看起来更多的输入XML文件问题给我。检查它是否包含此无效字符('İ'(0x0130)),并在必要时进行更正。如果您使用应用程序/游戏编写输入XML,请检查是否使用InvariantCulture编写内容。

Seems more an input XML file problem to me. Check if it contains this 'invalid' character ('İ' (0x0130) ) and correct it if necessary. If you wrote the input XML using your app/game, check if you are writing the contents using InvariantCulture as well.

Br,

这篇关于外国文化XML文本解析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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