View previous topic :: View next topic |
Author |
Message |
keinfarbton
Joined: 03 Dec 2005 Posts: 224 Location: Stuttgart - Germany
|
Posted: Thu Nov 01, 2007 5:53 pm Post subject: ICU 3.6? |
|
|
I try to convert from ISO-8859-15 to Utf8 with ICU. On my Ubuntu only ICU 3.6 is available, but this icu wrapper was written for 3.0/3.2. After changing ICU.d to load version 3.6 it links but I get a runtime exception. Is this because of I do not use the lib correctly or is it a problem that my version 3.6 is not completely compatible?
The code I tried:
Code: |
module t;
import mango.icu.UConverter;
import tango.io.FileConduit;
import tango.io.Stdout;
int main( char[][] args ){
auto cv = new UConverter( "ISO-8859-15" );
auto utfcv = new UConverter( "utf8" );
// transcoder mit source.createTrancoder( destination )
auto tc = cv.createTranscoder( utfcv );
ubyte[] ibuf = new ubyte[1024];
char[] obuf = new char[ ibuf.length * 4 ]; // absolute maximum
auto icond = new FileConduit( args[1] );
auto ocond = new FileConduit( args[2], FileConduit.WriteCreate );
UAdjust adj;
int isz;
while( (isz = icond.read( ibuf )) > 0 ){
tc.convert( ibuf[0..isz], obuf, adj, false ); // exception here
ocond.write( obuf[0..adj.output]);
}
tc.convert( null, obuf, adj, true );
ocond.write( obuf[0..adj.output]);
ocond.close;
return 0;
} |
The internal returned error code of ucnv_convertEx is 1==U_ILLEGAL_ARGUMENT_ERROR (see unicode/utypes.h)
The exception occurs on the first call, even if the input does only contain ascii chars |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Sat Nov 03, 2007 2:07 am Post subject: |
|
|
Looks ok, Frank. I wonder if the API has changed? What does that error mean in this context? |
|
Back to top |
|
|
keinfarbton
Joined: 03 Dec 2005 Posts: 224 Location: Stuttgart - Germany
|
Posted: Sun Nov 04, 2007 9:04 am Post subject: |
|
|
In the header the function "ucnv_convertEx" is marked:
Quote: | What does that error mean in this context? |
I inserted a printf in the ICU.d testError function. So I know it is the error code 1 from ucnv_convertEx that causes the exception. |
|
Back to top |
|
|
kris
Joined: 27 Mar 2004 Posts: 1494 Location: South Pacific
|
Posted: Sun Nov 04, 2007 12:30 pm Post subject: |
|
|
but what does error-code 1 mean? |
|
Back to top |
|
|
|