[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

RubyCocoa 0.4.1: problem with stringValue (NSCharacterConversionException

Andreas Schwarz

3/26/2005 12:18:00 PM

Hi,

I'm trying the itunes_albums.rb example, but stringValue fails for an
album name that contains cyrillic characters:
2005-03-26 13:15:26.564 ruby[3995] *** Uncaught exception:
<NSCharacterConversionException> Conversion to encoding 30 failed for
string "ФабÑика звезд 4"

Is it possible to get the unconverted unicode string?

Andreas
3 Answers

kimura wataru

3/27/2005 11:00:00 AM

0

Thanks for your reporting.

That's a bug of RubyCocoa, maybe.
RubyCocoa calls method -[NSString cString] in some procedure. In this
method, an exception occurs when system cannot convert encoding of the
receiver string to "default encoding", not Unicode, without loss.
The default encoding is determined from your language setting on System
Preferences > International.


>Hi,
>
>I'm trying the itunes_albums.rb example, but stringValue fails for an
>album name that contains cyrillic characters:
>2005-03-26 13:15:26.564 ruby[3995] *** Uncaught exception:
><NSCharacterConversionException> Conversion to encoding 30 failed for
>string "??????·???? ???????? 4"
>
>Is it possible to get the unconverted unicode string?
>
>Andreas
>



Jonathan Paisley

4/11/2005 9:48:00 AM

0

On Sun, 27 Mar 2005 21:00:18 +0900, kimura wataru wrote:

> Thanks for your reporting.
>
> That's a bug of RubyCocoa, maybe.
> RubyCocoa calls method -[NSString cString] in some procedure. In this
> method, an exception occurs when system cannot convert encoding of the
> receiver string to "default encoding", not Unicode, without loss. The
> default encoding is determined from your language setting on System
> Preferences > International.

Would it be appropriate to replace all calls to [NSString cString] with
[NSString UTF8String]? (and set $KCODE='u' in Ruby)


kimura wataru

4/11/2005 10:58:00 PM

0

Hi,

I'm working for converting string with $KCODE. RubyCocoa will treat
string as UTF8 when $KCODE is "NONE".

$KCODE NSStringEncoding
---------------------------
NONE UTF8
UTF8 UTF8
EUC EUC
SJIS SJIS(MacJapanese)


>On Sun, 27 Mar 2005 21:00:18 +0900, kimura wataru wrote:
>
>> Thanks for your reporting.
>>
>> That's a bug of RubyCocoa, maybe.
>> RubyCocoa calls method -[NSString cString] in some procedure. In this
>> method, an exception occurs when system cannot convert encoding of the
>> receiver string to "default encoding", not Unicode, without loss. The
>> default encoding is determined from your language setting on System
>> Preferences > International.
>
>Would it be appropriate to replace all calls to [NSString cString] with
>[NSString UTF8String]? (and set $KCODE='u' in Ruby)
>