|
View:
New views
5 Messages
—
Rating Filter:
Alert me
|
|
|
Sequence and ascii charactersHi all!
I'm quite newbie to Io, I discovered it the year before, during summer holidays and I have to say I love it. All of you are doing a great job. Well, my problem is that I need to feed a Sequence object with a string that has ascii characters (and they have to be ascii, no other encoding) above 0x7F and later parse the Sequence to get every character. So I get the following: Io 20080107 Io> S := Sequence clone ==> Io> S appendSeq("aaa■aaa") Exception: compile error: "unmatched ()s" on line 1 character 1 --------- message 'Error' in '[unlabeled]' on line 0 But, I'm able to do the following instead: Io 20080107 Io> S := Sequence clone ==> Io> S appendSeq("aaa") ==> aaa Io> S append(254) ==> aaa■ Io> S appendSeq("aaa") ==> aaa■aaa Io> S byteAt(3) ==> 254 The same problem happens when I try to pass that kind of string as an argument to an Io program (and this is what I really need to do). Is there a way to do it like in the first example? Thank you very much and congratulations for the great, great job. Oscar. |
|
|
Re: Sequence and ascii charactersCurrently, Io treats interactive input, program code and program
arguments as UTF8 (ignoring locale, too). The only way you can pass non-UTF data to Io is through file read operations (e.g., standard input). Here's a piece of code I played around with to check it. I hope that helps. {{{ #!/usr/bin/env io p := method(s, for(i, 0, s size println, s at(i) println) ) # p(System args println at(1)) p(File standardInput contents) }}} Cheers, - Danya |
|
|
Re: Sequence and ascii charactersThank you very much.
I will give it a try. I want to embed Io into a C++ application which will pass the string to an Io program to be parsed. So I will see if the standardInput method will work for me. If not I will investage other methods to do it (maybe implementing an Io socket server and sending the strings via socket...) Regards. Oscar. On Tue, May 6, 2008 at 11:04 PM, Danya Alexeyevsky <me.dendik@...> wrote: > Currently, Io treats interactive input, program code and program > arguments as UTF8 (ignoring locale, too). The only way you can pass > non-UTF data to Io is through file read operations (e.g., standard > input). > > Here's a piece of code I played around with to check it. I hope that > helps. > > {{{ > #!/usr/bin/env io > > p := method(s, > for(i, 0, s size println, s at(i) println) > ) > > # p(System args println at(1)) > p(File standardInput contents) > }}} > > Cheers, > - Danya > > |
|
|
Re: Sequence and ascii charactersFinally, I found a solution that meets my requeriments using
iconv_open/iconv/iconv_close to convert a string from LATIN1 to UTF8 and then, in the Io program the parsing is done: myarg := System args at(0) d := Sequence clone //Latin1 Thorn letter is the string delimiter d append(254) l := myarg split(d) That´s all. Oscar. PD: My aplogizes for not preppending "[Io]" to the subject. Sorry. On Wed, May 7, 2008 at 10:53 AM, Oscar Martinez <wasi.network@...> wrote: > Thank you very much. > > I will give it a try. > I want to embed Io into a C++ application which will pass the string to an > Io program to be parsed. So I will see if the standardInput method will work > for me. If not I will investage other methods to do it (maybe implementing > an Io socket server and sending the strings via socket...) > > Regards. > > Oscar. > > > > > > On Tue, May 6, 2008 at 11:04 PM, Danya Alexeyevsky <me.dendik@...> > wrote: > > > Currently, Io treats interactive input, program code and program > > arguments as UTF8 (ignoring locale, too). The only way you can pass > > non-UTF data to Io is through file read operations (e.g., standard > > input). > > > > Here's a piece of code I played around with to check it. I hope that > > helps. > > > > {{{ > > #!/usr/bin/env io > > > > p := method(s, > > for(i, 0, s size println, s at(i) println) > > ) > > > > # p(System args println at(1)) > > p(File standardInput contents) > > }}} > > > > Cheers, > > - Danya > > > > > > |
|
|
Re: Sequence and ascii charactersOn Wed, May 7, 2008 at 3:11 PM, Oscar Martinez <wasi.network@...> wrote:
> PD: My aplogizes for not preppending "[Io]" to the subject. Sorry. I think it's added automatically by the mailing list, no need to apologise. =P |
| Free Forum Powered by Nabble | Forum Help |