Commit bd721f03 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winex11: Directly use ntdll for utf8 conversion.

parent 6afcd71a
...@@ -914,12 +914,11 @@ static void *import_text_html( Atom type, const void *data, size_t size, size_t ...@@ -914,12 +914,11 @@ static void *import_text_html( Atom type, const void *data, size_t size, size_t
/* Firefox uses UTF-16LE with byte order mark. Convert to UTF-8 without the BOM. */ /* Firefox uses UTF-16LE with byte order mark. Convert to UTF-8 without the BOM. */
if (size >= sizeof(WCHAR) && ((const WCHAR *)data)[0] == 0xfeff) if (size >= sizeof(WCHAR) && ((const WCHAR *)data)[0] == 0xfeff)
{ {
len = WideCharToMultiByte( CP_UTF8, 0, (const WCHAR *)data + 1, size / sizeof(WCHAR) - 1, DWORD str_len;
NULL, 0, NULL, NULL ); RtlUnicodeToUTF8N( NULL, 0, &str_len, (const WCHAR *)data + 1, size - sizeof(WCHAR) );
if (!(text = malloc( len ))) return 0; if (!(text = malloc( str_len ))) return NULL;
WideCharToMultiByte( CP_UTF8, 0, (const WCHAR *)data + 1, size / sizeof(WCHAR) - 1, RtlUnicodeToUTF8N( text, str_len, &str_len, (const WCHAR *)data + 1, size - sizeof(WCHAR) );
text, len, NULL, NULL ); size = str_len;
size = len;
data = text; data = text;
} }
......
...@@ -437,22 +437,23 @@ static void sync_window_opacity( Display *display, Window win, ...@@ -437,22 +437,23 @@ static void sync_window_opacity( Display *display, Window win,
*/ */
static void sync_window_text( Display *display, Window win, const WCHAR *text ) static void sync_window_text( Display *display, Window win, const WCHAR *text )
{ {
UINT count; DWORD count, len;
char *buffer, *utf8_buffer; char *buffer, *utf8_buffer;
XTextProperty prop; XTextProperty prop;
/* allocate new buffer for window text */ /* allocate new buffer for window text */
len = lstrlenW( text );
count = WideCharToMultiByte(CP_UNIXCP, 0, text, -1, NULL, 0, NULL, NULL); count = WideCharToMultiByte(CP_UNIXCP, 0, text, -1, NULL, 0, NULL, NULL);
if (!(buffer = malloc( count ))) return; if (!(buffer = malloc( count ))) return;
WideCharToMultiByte(CP_UNIXCP, 0, text, -1, buffer, count, NULL, NULL); WideCharToMultiByte(CP_UNIXCP, 0, text, -1, buffer, count, NULL, NULL);
count = WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), NULL, 0, NULL, NULL); RtlUnicodeToUTF8N( NULL, 0, &count, text, len * sizeof(WCHAR) );
if (!(utf8_buffer = malloc( count ))) if (!(utf8_buffer = malloc( count )))
{ {
free( buffer ); free( buffer );
return; return;
} }
WideCharToMultiByte(CP_UTF8, 0, text, strlenW(text), utf8_buffer, count, NULL, NULL); RtlUnicodeToUTF8N( utf8_buffer, count, &count, text, len * sizeof(WCHAR) );
if (XmbTextListToTextProperty( display, &buffer, 1, XStdICCTextStyle, &prop ) == Success) if (XmbTextListToTextProperty( display, &buffer, 1, XStdICCTextStyle, &prop ) == Success)
{ {
......
...@@ -652,6 +652,7 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid ...@@ -652,6 +652,7 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid
VkPhysicalDeviceIDProperties id; VkPhysicalDeviceIDProperties id;
VkInstance vk_instance = NULL; VkInstance vk_instance = NULL;
VkDisplayKHR vk_display; VkDisplayKHR vk_display;
DWORD len;
BOOL ret = FALSE; BOOL ret = FALSE;
VkResult vr; VkResult vr;
...@@ -723,7 +724,8 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid ...@@ -723,7 +724,8 @@ static BOOL get_gpu_properties_from_vulkan( struct gdi_gpu *gpu, const XRRProvid
gpu->vendor_id = properties2.properties.vendorID; gpu->vendor_id = properties2.properties.vendorID;
gpu->device_id = properties2.properties.deviceID; gpu->device_id = properties2.properties.deviceID;
} }
MultiByteToWideChar( CP_UTF8, 0, properties2.properties.deviceName, -1, gpu->name, ARRAY_SIZE(gpu->name) ); RtlUTF8ToUnicodeN( gpu->name, sizeof(gpu->name), &len, properties2.properties.deviceName,
strlen( properties2.properties.deviceName ) + 1 );
ret = TRUE; ret = TRUE;
goto done; goto done;
} }
...@@ -749,6 +751,7 @@ static BOOL xrandr14_get_gpus2( struct gdi_gpu **new_gpus, int *count, BOOL get_ ...@@ -749,6 +751,7 @@ static BOOL xrandr14_get_gpus2( struct gdi_gpu **new_gpus, int *count, BOOL get_
INT primary_provider = -1; INT primary_provider = -1;
RECT primary_rect; RECT primary_rect;
BOOL ret = FALSE; BOOL ret = FALSE;
DWORD len;
INT i, j; INT i, j;
screen_resources = xrandr_get_screen_resources(); screen_resources = xrandr_get_screen_resources();
...@@ -803,7 +806,8 @@ static BOOL xrandr14_get_gpus2( struct gdi_gpu **new_gpus, int *count, BOOL get_ ...@@ -803,7 +806,8 @@ static BOOL xrandr14_get_gpus2( struct gdi_gpu **new_gpus, int *count, BOOL get_
if (get_properties) if (get_properties)
{ {
if (!get_gpu_properties_from_vulkan( &gpus[i], provider_info )) if (!get_gpu_properties_from_vulkan( &gpus[i], provider_info ))
MultiByteToWideChar( CP_UTF8, 0, provider_info->name, -1, gpus[i].name, ARRAY_SIZE(gpus[i].name) ); RtlUTF8ToUnicodeN( gpus[i].name, sizeof(gpus[i].name), &len, provider_info->name,
strlen( provider_info->name ) + 1 );
/* FIXME: Add an alternate method of getting PCI IDs, for systems that don't support Vulkan */ /* FIXME: Add an alternate method of getting PCI IDs, for systems that don't support Vulkan */
} }
pXRRFreeProviderInfo( provider_info ); pXRRFreeProviderInfo( provider_info );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment