I need help with GDAL. The string value with Chinese symbols is not readed/saved correctly (C#).
For SAVING grid value we using:
private static extern void GDALRATSetValueAsString(IntPtr handle, int row, int field, [In][MarshalAs(UnmanagedType.LPStr)] string value);
method (c#) to save string value, it seems that this method saves string as ANSI string.
For READING:
private static extern IntPtr GDALRATGetValueAsString(IntPtr handle, int row, int field);
In. Example my string "银行Flamwood C2" There is for methods to get value by pointer (use in GDALRATGetValueAsString metho):
var pointer = GDALRATGetValueAsString(GDALRasterAttributeTableH, row, field);
a) var b = Marshal.PtrToStringUni(pointer); // value: "㼿汆浡潷摯䌠2"
b) var a = Marshal.PtrToStringAnsi(pointer); // value: "??Flamwood C2"
c) var c = Marshal.PtrToStringAuto(pointer); // value: "㼿汆浡潷摯䌠2"
d) var d = Marshal.PtrToStringBSTR(pointer); //Throws an error out of memory.
Q: So how I can get Unicode string with was saved (so I can get using this Marshal.PtrToStringUni(pointer)) or most likely how to save the Unicode string to GDALRAT (GDAL RAT - GDAL Raster Attribute Table)?
GDAL version: 1.11.1
I tried to set CharSet = CharSet.Unicode but id does not helped, still get not correct string:
[DllImport(GdalWrapper.GdalDLL, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Unicode)]
private static extern void GDALRATSetValueAsString(IntPtr handle, int row, int field, [In][MarshalAs(UnmanagedType.LPStr)] string value);
Thanks for any help.
P.S. If the GDAL source files need to be build again to save string as unicode string, then what build parameters and where has to be set?