Forums | Admin

Discussion Forums: help

Start New Thread Start New Thread

 

By: Kim Kantola
RE: Iconv::IllegalSequence in encodings.rb [ reply ]  
2010-07-22 15:58
Hello,
I have tried to use the following line :
Spreadsheet.client_encoding = 'CP1252'

in my code, but am still getting an exception at

spreadsheet-0.6.4.1/lib/spreadsheet/encodings.rb:24:in `iconv'

The exception message is just a long string like this : "\0004\0005\000" is there any way to catch this exception in a more meaningful way so that I can tell the user that there are improper characters in the file?

Thank you!
Kim

By: Paul Trunz
RE: Iconv::IllegalSequence in encodings.rb [ reply ]  
2010-02-02 01:16
Of course I am even later than Hannes, but I just worked around the name Kubišová in a 6000+ line Windows generated Excel File and had a similar problem (not quite sure if 'scaron'-character really makes it through all the browsers and posting software though).

It turned out that this character is not part of the ISO-8859-1 charset but it is contained in the Windows specific charset CP1252 (also known as MS-ANSI or WINDOWS-1252 to my version of iconv). This of course pointed out the problem immediately

Spreadsheet.client_encoding = 'CP1252'

was all I needed (and of course specify the same to my Iconv-object which converted it to more standardized utf-8 :-)

I suspect this to be the default charset for Windows generated Excel files, but have not done any research on this. Anyways, one more thing you can try. According to

http://www.pemberley.com/janeinfo/latin1.html

however, the scaron character is one of the few which might appear in regular text that is *not* part of ISO-8859-1 and ³ does not seem to be one of them. I guess the problem has been solved for quite some time, but I wanted to get rid of this too, having spent some 45 minutes figuring it out :-)

Greetings :: Patru ""

By: Hannes Wyss
RE: Iconv::IllegalSequence in encodings.rb [ reply ]  
2009-09-14 14:17
Rainer

could you post your code (provided this is still a problem, I realize I'm a bit late responding).

At the moment I can only speculate: the fact that your "³" is printed as \263 leads me to the conclusion that what you're feeding into the Excel is iso-8859-1 encoded data. That should work as long as you have set your Spreadsheet.client_encoding = 'ISO-8859-1' (the default value is 'UTF-8')

Is it possible that a simple encoding-mixup is what we're dealing with here?

cheers
Hannes

By: Rainer Blessing
Iconv::IllegalSequence in encodings.rb [ reply ]  
2009-07-30 09:44
Iconv.iconv in row 23 of encodings.rb can not convert some special characters like ² and ³.
The data was imported by the spreadsheet gem, but exporting is not working.
I tried to replace the characters with normal ascii characters but I couldn't create an if condition for these characters.
The "³" is printed as \263 for example.


Rainer