c# - Substring for thai language -
i facing interesting problem. following string want take sub string.
1¨Ñ§ËÇÑ´1xxxxxxxx
index 0-2 (length 3) province id index 3-35 (length 32) province name in thai.
when try take sub string province following
string line = "1¨Ñ§ËÇÑ´1xxxxxxxx "; line.substring(3,32).trim();
this shows me error following
index , length must refer location within string.
keep in mind when debug code line total length shows me 33 should 35. , province sub string shown 30.
following code...
using (streamreader streamreader = new streamreader("file06.txt")) { console.writeline(".................. content of " + file.name + ".............."); string codeofprovince, nameofprovince, line; while ((line = streamreader.readline()) != null) { codeofprovince = line.substring(0, 3).trim(); nameofprovince = line.substring(3,32).trim(); console.writeline("codeofprovince {0}, nameofprovince {1}", codeofprovince , nameofprovince ); } console.writeline(".............................................................."); console.writeline();
i'm sure out , file has following data
1¨Ñ§ËÇÑ´1xxxxxxxx 2¨Ñ§ËÇÑ´2xxxxxxxx
ok got answer. reading file ansi encoding. when changed file unicode encoding started working.
Comments
Post a Comment