Ho bisogno di aiuto con GDAL. Il valore stringa con simboli cinesi non viene letto/salvato correttamente (C#).GDAL GDALRATSetValueAsString() come salvare i caratteri cinesi (C#)?
Per RISPARMIO valore griglia si utilizza:
static GDALRATSetValueAsString vuoto extern privato (maniglia IntPtr, fila int, campo int [In] [MarshalAs (UnmanagedType.LPStr)] valore di stringa); metodo (C#) per salvare il valore stringa, sembra che questo metodo salva stringa come stringa ANSI.
per la lettura:
private static extern IntPtr GDALRATGetValueAsString(IntPtr handle, int row, int field);
In. Esempio mia stringa "银行 Flamwood C2" C'è per i metodi per ottenere valore puntatore (uso 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.
D: Allora, come posso ottenere stringa Unicode con è stato salvato (così posso ottenere utilizzando questo Marshal.PtrToStringUni (puntatore)) o molto probabilmente come salvare la stringa Unicode su GDALRAT (GDAL RAT - Tabella attributi raster GDAL)?
versione GDAL: 1.11.1
ho cercato di impostare charset = CharSet.Unicode ma ID non ha aiutato, ancora ottenere non corretto stringa:
[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);
Grazie per qualsiasi aiuto.
P.S. Se i file di origine GDAL devono essere di nuovo creati per salvare la stringa come stringa unicode, quali sono i parametri di costruzione e dove deve essere impostato?
Trovato questo collegamento: https://trac.osgeo.org/gdal/wiki/rfc5_unicode. Forse c'è un modo facile (questo articolo è stato scritto 5 anni fa ...)? – Drasius
Anche ticket creato: https://trac.osgeo.org/gdal/ticket/6168#ticket – Drasius
incolla la tua soluzione –