From: Cai Li Date: 2005-01-31T21:38:31+09:00 Subject: split string -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 My job is to split the following string which contains some chinese chars(GB code) and make an array: "sz000503,????,2005-01-31 15:01:01,11.780,11.950,11.800,-0.170,11.640,11.930,-1.42%,61454,7231.56,11.770,11.790,-60.52%,11.77 / 96,11.76 / 197,11.75 / 195,11.79 / 177,11.80 / 611,11.81 / 424,11.73 / 85,11.72 / 70,11.82 / 528,11.83 / 873" my own script looks like this: def make_array(orig_string) rb_array = Array.new elements = '' orig_string.each_byte {|s| if sprintf("%c",s) != ',' then elements = elements + sprintf("%c",s) else rb_array.push(elements) elements = '' end } return rb_array end with the following results: ["sz000503", "\272\243\272\347\277\330\271\311", "2005-01-31 15:01:01", "11.780", "11.950", "11.800", "-0.170", "11.640", "11.930", "-1.42%", "61454", "7231.56", "11.770", "11.790", "-60.52%", "11.77 / 96", "11.76 / 197", "11.75 / 195", "11.79 / 177", "11.80 / 611", "11.81 / 424", "11.73 / 85", "11.72 / 70", "11.82 / 528"] Almost right except chinese chars.Then how to save chinese? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (MingW32) - WinPT 0.7.96rc1 iD8DBQFB/iZGVLC4xCNBi2kRAngyAJ4lJew59t3OpUYFeY3rdt7cW0C/wgCdFk8g owog0jOeOyJq2OsvbfJlpvk= =9Unz -----END PGP SIGNATURE-----