블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-20 00:00

[링크] https://lunchballer.com/archives/1326

 

[Unity-C#] 특정 국가에서 크래시가 난다면 CultureInfo를 확인하자

Unity 2019부터 .NET 3.5는 더 이상 지원되지 않고, .NET Standard 2.0과 .NET 4.X가 지원된다. .NET Standard 2.0/.NET 4.X은 Unity 2017까지 사용하던 .NET 2.0/.NET 2.0 Subset과 같지 않다. 그래서 글로벌 게임을 서비스 중

lunchballer.com

 

[참조] https://mentum.tistory.com/615

 

Float.Parse not in a correct format 문화권 문제

숫자 변환에서 오류가 발생하다 게임 개발을 하다 보면 string에서 float로 파싱 하여 사용해야 하는 경우가 꽤나 자주 발생한다. 예를 들어, 연출 데이터에서 0.5초 동안 정지한다거나 하는 경우 다

mentum.tistory.com

 

[체크해야 될 함수] 더 있을수도..

float.Parse / float.TryParse / float.ToString

double.Parse / double.TryParse / double.ToString

int.Parse / int.TryParse / int.ToString

long.Parse / long.TryParse / long.ToString

BigInteger.Parse / BigInteger.TryParse  / BigInteger.ToString

DateTime.Parse / DateTime.ParseExact / DateTime.TryParse / DateTime.TryParseExact / DateTime.ToString

TypeConverter.ConvertFrom / TypeConverter.ConvertTo

Convert.To??? 시리즈(Convert.ToInt16/ToInt32/ToInt64/ToUInt16/ToUInt32/ToUInt64,ToDecimal,ToDouble,ToSByte,ToSingle 등)

.ToLower / .ToUpper

string.Format

 

 

[첨언]

Unity 2018에서 Unity 2021로 포팅을 하고 업데이트를 했는데 이상한 에러가 크래시레포트에 많이 수집돼서 확인해보니

위의 링크에 보이는 문제로 보인다.

Unity 2019 부터 바뀐부분이 있어서(참조 링크 보면 됨) int float double BigInteger 등을 Parse 할 때 System.Globalization.CultureInfo.InvariantCulture을 무조건 넣어줘야 될 것 같다.

(CurrnetCulture는 건들면 문제가 생길 것 같아서 그냥 노가다로 다 넣었다.)

 

P.s. 문화권 문제라 한국에서는 아무리 테스트를 해도 크래시가 안나니 무슨 버그인지 몰라서 한참 헤멤..

 

[추가]

CultureInfo 관련 이슈가 있는 함수가 더 있어서 추가해 둠.

아래 함수 2개를 문화권 영향받지 않도록 변경했다.

이 두 함수는 함수 자체가 문화권 영향받지 않는 함수가 있어서 편한 것 같다.

 

TypeConverter.ConvertFrom() → TypeConverter.ConvertFromInvariantString()

TypeConverter.ConvertTo() → TypeConverter.ConvertToInvariantString()

 

[참고] https://learn.microsoft.com/ko-kr/dotnet/api/system.componentmodel.int32converter?view=net-7.0 

 

Int32Converter 클래스 (System.ComponentModel)

32비트 부호 있는 정수 개체와 다른 표현 사이를 변환하는 형식 변환기를 제공합니다.

learn.microsoft.com

 

[나라별 숫자표기 참고] https://theqoo.net/square/298509638

 

나라별로 다른 소수점과 천의 자리 구분 기호 - 스퀘어 카테고리

형태국가1,234,567.89호주, 캐나다 (영어권, 비공식), 중국, 홍콩, 아일랜드, 이스라엘, 일본, 한국, 말레이시아, 멕시코, 뉴질랜드, 파키스탄, 필리핀, 싱가포르, 대만, 태국, 영국, 미국1234567.89국제단

theqoo.net

[숫자표기 참고2] https://docs.oracle.com/cd/E19683-01/816-3980/overview-48/index.html

 

숫자 (국제 언어 환경 설명서)

숫자 영국과 미국은 소수 자릿수를 마침표를 사용해 표시하는 몇 안 되는 국가들 중 두 국가입니다. 그 밖의 많은 국가들은 마침표 대신 콤마를 사용합니다. 소수 구분 기호는 기수 문자라고도

docs.oracle.com

 

[Date format by country] https://gist.github.com/mlconnor/1887156

 

Listing of countries with their preferred date formats, ISO3166 code, ISO629-2

Listing of countries with their preferred date formats, ISO3166 code, ISO629-2 - country_date_formats.csv

gist.github.com

 

 

반응형
Posted by blueasa
, |