diff options
author | Tijoy Tom Kalathiparambil <tijoytk@microsoft.com> | 2016-05-03 14:25:22 -0700 |
---|---|---|
committer | tijoytk <tijoytk@microsoft.com> | 2016-05-06 18:26:29 -0700 |
commit | e63ae93ca3fc777ff25930491332e07cf79a9ce3 (patch) | |
tree | a2baee2f867d93cf8ffdc44a1bb146588c808f18 /src/vm/fieldmarshaler.h | |
parent | 92f671fe9f0fc583805d4f9c3116126444dabcf4 (diff) | |
download | coreclr-e63ae93ca3fc777ff25930491332e07cf79a9ce3.tar.gz coreclr-e63ae93ca3fc777ff25930491332e07cf79a9ce3.tar.bz2 coreclr-e63ae93ca3fc777ff25930491332e07cf79a9ce3.zip |
UTF8 Marshaling support(UnmanagedType.LPUTF8Str)
Usage: [MarshalAs(UnmanagedType.LPUTF8Str)] applied to string
and stringbuilder.
Implementation mostly use Encoding.UTF8 API to do the byte buffer
to string roundtripping. Introducing two new marshalers,
UTF8StringMarshaler and UTF8BufferMarshaler which handle string
and StringBuilder respectively. [Out] StringBuilder marshaling use
builder capacity as the buffer size ie (builder. Capacity + 1) *3
which is enough for any UTF8 char in BMP plane, infact Encoding.UTF8
mscorlib APIs use the same length.All marshaling flags(ThrowOnUnmapable,
defaultchar) are ignored since they do not make sense in UTF16 to UTD8
context.
The public contracts are not yet updated, the public contracts and
public marshaling API (Marshal.PtrToStringUtf8 and StringToHGlobalUtf8)
will be added once the implementation is in. The marshal api are anyway
going to be a wrapper around Encoding.GetBytes and GetChars.
Diffstat (limited to 'src/vm/fieldmarshaler.h')
-rw-r--r-- | src/vm/fieldmarshaler.h | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/vm/fieldmarshaler.h b/src/vm/fieldmarshaler.h index 3c06528499..9ec7e87610 100644 --- a/src/vm/fieldmarshaler.h +++ b/src/vm/fieldmarshaler.h @@ -757,6 +757,19 @@ public: ELEMENT_SIZE_IMPL(sizeof(LPWSTR), sizeof(LPWSTR)) }; +//======================================================================= +// LPUTF8STR <--> System.String +//======================================================================= +class FieldMarshaler_StringUtf8 : public FieldMarshaler +{ +public: + + VOID UpdateNativeImpl(OBJECTREF* pCLRValue, LPVOID pNativeValue, OBJECTREF *ppCleanupWorkListOnStack) const; + VOID UpdateCLRImpl(const VOID *pNativeValue, OBJECTREF *ppProtectedCLRValue, OBJECTREF *ppProtectedOldCLRValue) const; + VOID DestroyNativeImpl(LPVOID pNativeValue) const; + + ELEMENT_SIZE_IMPL(sizeof(LPSTR), sizeof(LPSTR)) +}; //======================================================================= // LPSTR <--> System.String |