Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
296 views
in Technique[技术] by (71.8m points)

c# - foreign culture XML text parsing

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 - 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

and here is the stack trace:

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)

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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,


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...