Monday, December 20, 2010

[android-developers] Re: Illegal continuation byte in NewStringUTF

Just as a matter of practice, ALL of your source files (and data files
over which you have any control), should be stored exclusively as
UTF-8.

This will avoid this problem, and many, many others. Think how much
time you'd saved, just by making sure that you toolset is set to use
UTF-8 before you begin.

In this day and age, it makes no sense to be using decades-outmoded
standards that simply do not meet the needs of the modern connected
world.

On Dec 20, 1:22 am, Luca Carlon <carlon.l...@gmail.com> wrote:
> I suppose you were right. I changed the encoding the the string and it
> seems to be correct now. No more segfaults.
> Thanks!
>
> On Dec 16, 8:42 pm, ip332 <iprile...@gmail.com> wrote:
>
>
>
>
>
>
>
> > There is nothing strange.
> > You have a C string, something like that:
> > char* fileName = "Dracula Der Pfähler.mp3"
> > When you typed this text it was converted into 8-bit code (single
> > byte, ISO encoding).
> > So there is nothing strange that NewStringUTF() complains about
> > "illegal continuation byte" because fileName is not UTF8 encoded
> > string.
> > You need convert this string into UTF8 (aka "multibyte") first, then
> > call NewStringUTF().
>
> > On Dec 16, 9:46 am, Luca Carlon <carlon.l...@gmail.com> wrote:
>
> > > Hi! I'm trying to create a jstring using NewStringUTF but I
> > > experienced a strange issue when the C string passed to the function
> > > contains characters not ASCII (i.e. accented characters). This is what
> > > I get:
>
> > > 01-01 02:56:41.719: WARN/(1738): Creating the jstring for Dracula Der
> > > Pfähler.mp3.
> > > 01-01 02:56:41.719: WARN/dalvikvm(1738): JNI WARNING: illegal
> > > continuation byte 0x68
> > > 01-01 02:56:41.719: WARN/dalvikvm(1738):              string: 'Dracula
> > > Der Pfähler.mp3'
> > > 01-01 02:56:41.719: WARN/dalvikvm(1738):              in <method_name>
> > > (NewStringUTF)
>
> > > where the first line is created using the char* and the android log
> > > functions. This is the piece of code:
>
> > > jstring pathStr;
> > > LOGW("Creating the jstring for %s.", fileName);
> > > if ((pathStr = mEnv->NewStringUTF(fileName)) == NULL) {
> > >    LOGE("Failed NewStringUTF.");
> > >    return false;}
>
> > > LOGW("The jstring has been created...");
>
> > > Any idea why this is happening?
> > > Thanks!

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment