[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [ercp-dev] first approach and fonts

An update on the issue. One of the PhoneME developers was so kind to
look into the problem to check if this is a eSWT or phoneME bug
(thanks Davy Preuveneers). It looks like the issue in the eRCP tracker
is in the right place.

It turnes out that in:

stringCharData = GetStringChars(env, string);
if (ExceptionCheck(env)) return ;
stringLength = GetStringLength(env, string);
uglstring = convertToNativeString(stringCharData, stringLength,
 &stringShouldFree);
error.error_code = 0;

GetStringChars is a JNI method. In that case phoneME returns a
non-null terminated pointer to a jchar array (a Unicode string). Then
convertToNativeString() transforms this jchar array into an internal
representation, but mistakenly assumes that stringCharData is
null-terminated. This method is implemented in eSWT and can be found
in:

http://dev.eclipse.org/viewcvs/viewvc.cgi/org.eclipse.ercp/eswt/win/org.eclipse.ercp.swt.core.win/win-native/bindings/impl/TypeConverter.c?root=RT_Project

J9 makes sure that all Unicode strings are null-terminated and the
eSWT code relies on it. Which is why J9 doesn't have the problem.

So to summarize it seems that eSWT wrongly assumes GetStringChars
returns null-terminated strings where it should not.
Unicode strings are not \0 terminated, whereas UTF-8 strings are (and
GetStringChars uses Unicode strings)
See sectopm 3.2.4 in:
http://java.sun.com/docs/books/jni/html/objtypes.html

I'm going to append this to the bug report.

Best regards,
Andrea










On Tue, Sep 6, 2011 at 2:47 PM, andrea antonello
<andrea.antonello@xxxxxxxxx> wrote:
> Thanks Mark,
>
>> It definitely sounds like a problem. I don't think there has been a fix put
>> into eRCP. If you open a defect and provide a patch we can get it into the
>> code base.
>
> I opened an issue in the tracker. Unfortunately I am not able to supply a fix.
> I will try to hunt down the person that fixed it already and kindly
> ask if he can provide his fix.
>
> best regards,
> Andrea
>
>
>
>>
>>
>>
>>
>>
>> From:        andrea antonello <andrea.antonello@xxxxxxxxx>
>> To:        ERCP developers list <ercp-dev@xxxxxxxxxxx>
>> Date:        09/05/2011 04:41 AM
>> Subject:        Re: [ercp-dev] first approach and fonts
>> Sent by:        ercp-dev-bounces@xxxxxxxxxxx
>> ________________________________
>>
>>
>> A small update on this (without evident solution, I am afraid).
>> Reading the comments on the following post:
>> http://jmj-eclipse.blogspot.com/2009/10/running-ercp-with-phoneme-advanced-on.html
>>
>> I saw the comment about the same problem I have:
>>
>> "I was able to resolve the issue with stray characters in the widget
>> texts (menu, button, etc.) by fixing one method in the eSWT C code. It
>> seems CVM does not handle Strings the same way J9 does. J9 will
>> automatically terminate the string with null values when passing
>> to/from JNI. CVM doesn't seem to do this. The fix was pretty simple,
>> since the length of the string was provided already."
>>
>> Does anyone know if this was addressed in the latest available
>> eRCP/eSWT or if this could be the problem I am facing?
>>
>> Best regards,
>> Andrea
>>
>>
>> On Wed, Aug 24, 2011 at 6:11 PM, andrea antonello
>> <andrea.antonello@xxxxxxxxx> wrote:
>>> Thanks for the reply Mark,
>>>
>>>> The eWorkbench is not coded to use any device/user preferences for font
>>>> size
>>>> since there is no standard way to obtain this info. So if on your
>>>> particular
>>>> device, the fonts are too small, the easiest thing to do is recompile the
>>>> eWorkbench plugin with your own font size specified.
>>>
>>> Ok, so I will have to tweak it, thanks for the pointer.
>>>
>>>> You typically see boxes instead of characters when the device font does
>>>> not
>>>> support the character being displayed. Some device manufacturers provide
>>>> additional fonts that you can download to the device. Make the new font
>>>> the
>>>> default, and most apps should use it and display the right characters.
>>>
>>> That is so strange, because even the default font shows the boxes. I
>>> also tried to set a Tahoma font, which is supposed to be present for
>>> sure in Windows Mobile and I get the same error. Also this only
>>> applies to spaces and striong endings (not \n, simply the end of the
>>> string, i.e. "COM4" gets "COM4[]" with the brackets being the box). I
>>> will  investigate further.
>>>
>>> Best regards,
>>> Andrea
>>>
>>>
>>>>
>>>>
>>>>
>>>> From:        andrea antonello <andrea.antonello@xxxxxxxxx>
>>>> To:        ercp-dev@xxxxxxxxxxx
>>>> Date:        08/24/2011 04:43 AM
>>>> Subject:        [ercp-dev] first approach and fonts
>>>> Sent by:        ercp-dev-bounces@xxxxxxxxxxx
>>>> ________________________________
>>>>
>>>>
>>>> Hi list,
>>>> I am quite new to the eRCP project and was successful in adding
>>>> applications to the eWorkbench using the phoneme jvm.
>>>> So far I am amazed about the possibility to go mobile developing in rcp.
>>>>
>>>> Due to the display size (I guess) of the device, the font is  way to
>>>> small to be readable, which is why I supplied custom fonts to the
>>>> widgets.
>>>> I could not find a way to do this in an overall way (themes do not
>>>> seem to be supported). I have 2 main problems:
>>>> - the eWorkbench parts are still small. Do I have to modify the plugin
>>>> directly to change the UI font or is there another way?
>>>> - the texts have strange rectangles [0] instead of the spaces
>>>>
>>>> Best regards,
>>>> Andrea
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> [0] as code 141 in the table here http://www.asciitable.it/asciiext.asp
>>>> _______________________________________________
>>>> ercp-dev mailing list
>>>> ercp-dev@xxxxxxxxxxx
>>>> https://dev.eclipse.org/mailman/listinfo/ercp-dev
>>>>
>>>>
>>>> _______________________________________________
>>>> ercp-dev mailing list
>>>> ercp-dev@xxxxxxxxxxx
>>>> https://dev.eclipse.org/mailman/listinfo/ercp-dev
>>>>
>>>>
>>>
>> _______________________________________________
>> ercp-dev mailing list
>> ercp-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/ercp-dev
>>
>>
>> _______________________________________________
>> ercp-dev mailing list
>> ercp-dev@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/ercp-dev
>>
>>
>