当前位置:网站首页>【Unity/C#】游戏出现区域性崩溃,深藏的国际化巨坑
【Unity/C#】游戏出现区域性崩溃,深藏的国际化巨坑
2022-04-22 19:56:00 【城府依旧】
正在全球范围大推的项目出现了一个诡异的Bug,测试爆肝都测不出来的那种。经过后台数据分析,这个诡异的Bug居然有明显的区域性,几乎全部出现在德国和法国。
把代码里与国际化相关的逻辑统统规避掉之后仍然无法解决。
一个偶然的机会被保加利亚的美术小哥复现了Bug,原来,当手机设置为保加利亚语,游戏才会出现Bug,切换到其它语言一切正常。
在肝掉几十根头发之后,终于定位到了问题所在,原来是代码解析配置表中的float数值失败。
它的罪魁祸首就是float.Parse()方法,原来C#非常贴心(多管闲事)的帮我们做了国际化处理。在有些国家的标准中,逗号才是小数点!!! 所以配置表里的小数点float.Parse不认了。"1.5"要写成"1,5"才能正常转换。
float.Parse()的重载方法是可以传入文化区分的:
指定float解析方式为英标:
float.Parse("9.99", CultureInfo.CreateSpecificCulture("en-GB"));
指定float解析方式为德标:
float.Parse("9.99", CultureInfo.CreateSpecificCulture("de-DE"));
所有float.Parse()都这么改还不得累死,万一还有其它类型有标准差异呢?
可以直接强制设置系统的全局文化标准:
using System.Globalization;
CultureInfo.CurrentCulture = CultureInfo.CreateSpecificCulture("en-GB");
这个Bug很简单,就是很费钱。。。德法的买量钱打水漂了。。
版权声明
本文为[城府依旧]所创,转载请带上原文链接,感谢
https://blog.csdn.net/final5788/article/details/124002633
边栏推荐
- Problems that must be avoided in the process of top survey technology sorting and transformation
- 怎么才能申购新股呢?申购新股安全吗?
- 应届毕业生的头一份工作有多重要?
- 2022年Postman最被低估的功能,自动化接口测试效率简直无敌
- How can I apply for convertible bonds? Is it safe to purchase convertible bonds?
- If else optimization
- [渝粤教育] 南阳理工学院 英语漫话中国文化 参考 资料
- Don't say, "I don't like development, so I choose testing."
- This is why deep learning is so powerful
- [leetcode daily question] rotation function
猜你喜欢

高级ipc - dbus详解

从功能测试到自动化测试,待遇翻倍,我整理了这一份3000字超全学习指南

Implementation of calico official website network topology: Based on ENSP and vmvare

The origin explanation and use example of image pre training model
![[eight part essay] redis cache](/img/a2/ec1b1b7b27692d1c55d1bbf1138f9f.png)
[eight part essay] redis cache

Obtain the real IP address of the client after envoy proxy

软件测试入行必看,一文800字教你Allure 测试报告环境搭建

Household intelligent projector is the first choice, entering the polar meter h3s projection

家用智能投影仪首选,走进极米H3S投影

envoy代理后获取客户端真实IP
随机推荐
What if I don't understand? Google's 540 billion parameter new model can explain the laugh point and guess the movie through Emoji expression
What is the reason why the camera device with built-in 4G card of Haikang cannot register with easycvr platform?
calico官网网络拓扑实现:基于eNSP与VMVare
What is the reason why easycvr streaming media kernel cannot be started?
[eight part essay] thread safety
一文读懂Hoo Smart Chain的可视化公链
2021-06-10 axure本地发布
Golang本地缓存选型对比及原理总结
Quarkus dependency injection 9: bean read / write lock
This is why deep learning is so powerful
应届毕业生的头一份工作有多重要?
2021应届毕业生该何去何从?
Issued locally by Axure on June 10, 2021
The swindler made nearly 180 million profits with AI voice. Victim: can't you tell it's a robot
Problems that must be avoided in the process of top survey technology sorting and transformation
Recommendation of 5 papers on the application of reinforcement learning in the financial field
Pytorch deep learning practice 09 multi classification questions
Anaconda creates a new environment and installs the GPU version of pytorch
EasyCVR流媒体内核无法启动是什么原因?
【八股文】Redis缓存