[ 
https://issues.apache.org/jira/browse/GEODE-9412?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17377564#comment-17377564
 ] 

ASF subversion and git services commented on GEODE-9412:
--------------------------------------------------------

Commit b8fdb0f7044cb78ba11898c2d0a3dbbc04f60cf0 in geode-native's branch 
refs/heads/develop from Jacob Barrett
[ https://gitbox.apache.org/repos/asf?p=geode-native.git;h=b8fdb0f ]

GEODE-9412: Fixes translation of String between .NET and C++ (#829)

Adds new String.hpp similar to C++ client's string.hpp.
Converts String to std::string via UTF-16 to UTF-8 transform.
Converts std::string to String via UTF-8 to UTF-16 transform.
Adds basic unit tests for String.hpp methods.

Adds basic unit tests for Serializable.

Splits the .NET library into objects and assembly so that unit tests
can link directly against the objects to avoid symbol export issues
crossing C++/CLI layers.

Fixes ACE PDB location so it can be correctly included in dependent projects.

> App crashes when translating string with certain Unicode characters 
> (exception thrown across managed/native boundary)
> ---------------------------------------------------------------------------------------------------------------------
>
>                 Key: GEODE-9412
>                 URL: https://issues.apache.org/jira/browse/GEODE-9412
>             Project: Geode
>          Issue Type: Bug
>          Components: native client
>            Reporter: Blake Bender
>            Priority: Major
>              Labels: pull-request-available
>
> tl;dr, we're not translating unicode correctly between .net and C++.
> When a unicode string comes into the CLI layer, we use 
> `marshal_as<std::string>` to translate, then assume this yields UTF-8.  In 
> fact, what it yields is a string encoded in a) whatever the local code page 
> is for the system, or b) the default code page for the app, if one exists in 
> the manifest.  In the C++ layer, we then assume the string is UTF-8, and for 
> a PUT, attempt to translate into Java-modified UTF-8, which ends up throwing 
> an uncaught exception when it encounters a character that is not a valid 
> UTF-8 start code.  When this exception hits the native/managed boundary, the 
> app crashes.
> To avoid this issue, we need to `marshal_as<std::wstring>`, then use `std` 
> conversion functions to arrive at UTF-8, and pass that down to the C++ layer. 
>  We also need to use the reverse process when sending strings back up to CLI.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to