Hello,
I have trouble using rb_str_new[2] and German umlauts.
The umlauts will be escaped:
c program:
static VALUE test(VALUE self, VALUE word) {
char *str = STR2CSTR(word);
printf(“got: %s\n”, str);
return rb_str_new2(str);
}
from ruby:
p foo.test(“Fälschung”)
will print:
got: Fälschung
“F\344lschung”
Both worlds (c and ruby) handle the string correctly, but
the translation fails.
Do I have to adjust the encoding? Some idea?
Best regards,
Matthias
···
Do You Yahoo!?
Yahoo! Finance - Get real-time stock quotes
http://finance.yahoo.com
Hi,
from ruby:
p foo.test(“F�älschung”)
will print:
got: F�älschung
“F\344lschung”
Both worlds (c and ruby) handle the string correctly, but
the translation fails.
Do I have to adjust the encoding? Some idea?
I need more info. The string from test is shorter than the original?
I guess it should print
will print:
got: F�älschung
“F\201\344lschung”
I don’t know yet why \201 was dropped (due to String#inspect escaping).
matz.
···
In message “c-api: rb_str_new” on 02/08/28, Matthias Veit matthias_veit@yahoo.de writes:
Hi,
“Matthias Veit” matthias_veit@yahoo.de wrote in message
news:20020828021424.20f202ee.matthias_veit@yahoo.de …
Hello,
I have trouble using rb_str_new[2] and German umlauts.
The umlauts will be escaped:
c program:
static VALUE test(VALUE self, VALUE word) {
char *str = STR2CSTR(word);
printf(“got: %s\n”, str);
return rb_str_new2(str);
}
from ruby:
p foo.test(“Fälschung”)
will print:
got: Fälschung
“F\344lschung”
Both worlds (c and ruby) handle the string correctly, but
the translation fails.
Do I have to adjust the encoding? Some idea?
Best regards,
Matthias
Try this:
$KCODE = ‘n’
p “F\344lschung”
$KCODE = ‘u’
p “F\344lschung”
Park Heesob
Hello,
from ruby:
p foo.test(“F�älschung”)
I need more info. The string from test is shorter than the original?
I guess it should print
I used the umlaut, that is false printed. The word was:
foo.test(“F#lschung”) where # is one german umlaut (The length
of the string is 9).
The string returned from test has an escaped umlaut, but the
length of the string is the same: 9.
ruby: (where # is the German umlaut “a” with two points on top)
s=“F#lschung”
t=a.test(s)
p s.length
p t
p t.length
will print:
got: F#lschung
9
“F\344lschung”
9
Best Regards,
Matthias
···
YM == matz@ruby-lang.org (Yukihiro Matsumoto) wrote:
Do You Yahoo!?
Sign up for SBC Yahoo! Dial - First Month Free
Get the latest in news, entertainment, sports, weather and more on Currently.com. Sign up for free email service with AT&T Yahoo Mail.