mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-14 18:15:28 -04:00
Platform_EncodeString --> Platform_EncodeUtf8/Utf16, because it's important to know the actual encoding
E.g. if you were trying to use libcurl http backend on windows, Platform_EncodeString would encode the string as utf16. But libcurl requires utf8 strings.
This commit is contained in:
parent
dde41af49c
commit
458bd587a2
@ -508,7 +508,7 @@ void Game_TakeScreenshot(void) {
|
|||||||
String_Format3(&filename, "-%p2-%p2-%p2.png", &now.hour, &now.minute, &now.second);
|
String_Format3(&filename, "-%p2-%p2-%p2.png", &now.hour, &now.minute, &now.second);
|
||||||
|
|
||||||
#ifdef CC_BUILD_WEB
|
#ifdef CC_BUILD_WEB
|
||||||
Platform_EncodeString(str, &filename);
|
Platform_EncodeUtf8(str, &filename);
|
||||||
EM_ASM_({
|
EM_ASM_({
|
||||||
var name = UTF8ToString($0);
|
var name = UTF8ToString($0);
|
||||||
var canvas = Module['canvas'];
|
var canvas = Module['canvas'];
|
||||||
|
@ -345,7 +345,7 @@ static void Http_DownloadAsync(struct HttpRequest* req) {
|
|||||||
|
|
||||||
String_InitArray(url, urlBuffer);
|
String_InitArray(url, urlBuffer);
|
||||||
Http_BeginRequest(req, &url);
|
Http_BeginRequest(req, &url);
|
||||||
Platform_EncodeString(urlStr, &url);
|
Platform_EncodeUtf8(urlStr, &url);
|
||||||
|
|
||||||
EM_ASM_({
|
EM_ASM_({
|
||||||
var url = UTF8ToString($0);
|
var url = UTF8ToString($0);
|
||||||
@ -606,7 +606,7 @@ static cc_result Http_BackendDo(struct HttpRequest* req, cc_string* url) {
|
|||||||
_curl_easy_setopt(curl, CURLOPT_HTTPHEADER, req->meta);
|
_curl_easy_setopt(curl, CURLOPT_HTTPHEADER, req->meta);
|
||||||
|
|
||||||
Http_SetCurlOpts(req);
|
Http_SetCurlOpts(req);
|
||||||
Platform_EncodeString(urlStr, url);
|
Platform_EncodeUtf8(urlStr, url);
|
||||||
_curl_easy_setopt(curl, CURLOPT_URL, urlStr);
|
_curl_easy_setopt(curl, CURLOPT_URL, urlStr);
|
||||||
|
|
||||||
if (req->requestType == REQUEST_TYPE_HEAD) {
|
if (req->requestType == REQUEST_TYPE_HEAD) {
|
||||||
|
@ -1320,13 +1320,13 @@ static void DownloadMap(const cc_string* path) {
|
|||||||
char strFile[NATIVE_STR_LEN];
|
char strFile[NATIVE_STR_LEN];
|
||||||
cc_string file;
|
cc_string file;
|
||||||
cc_result res;
|
cc_result res;
|
||||||
Platform_EncodeString(strPath, path);
|
Platform_EncodeUtf8(strPath, path);
|
||||||
|
|
||||||
/* maps/aaa.schematic -> aaa.cw */
|
/* maps/aaa.schematic -> aaa.cw */
|
||||||
file = *path; Utils_UNSAFE_GetFilename(&file);
|
file = *path; Utils_UNSAFE_GetFilename(&file);
|
||||||
file.length = String_LastIndexOf(&file, '.');
|
file.length = String_LastIndexOf(&file, '.');
|
||||||
String_AppendConst(&file, ".cw");
|
String_AppendConst(&file, ".cw");
|
||||||
Platform_EncodeString(strFile, &file);
|
Platform_EncodeUtf8(strFile, &file);
|
||||||
|
|
||||||
res = EM_ASM_({
|
res = EM_ASM_({
|
||||||
try {
|
try {
|
||||||
@ -1586,7 +1586,7 @@ static void TexturePackScreen_LoadEntries(struct ListScreen* s) {
|
|||||||
#include <emscripten.h>
|
#include <emscripten.h>
|
||||||
static void TexturePackScreen_UploadCallback(const cc_string* path) {
|
static void TexturePackScreen_UploadCallback(const cc_string* path) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf8(str, path);
|
||||||
|
|
||||||
/* Move from temp into texpacks folder */
|
/* Move from temp into texpacks folder */
|
||||||
/* TODO: This is pretty awful and should be rewritten */
|
/* TODO: This is pretty awful and should be rewritten */
|
||||||
|
@ -340,7 +340,7 @@ int Directory_Exists(const cc_string* path) {
|
|||||||
TCHAR str[NATIVE_STR_LEN];
|
TCHAR str[NATIVE_STR_LEN];
|
||||||
DWORD attribs;
|
DWORD attribs;
|
||||||
|
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf16(str, path);
|
||||||
attribs = GetFileAttributes(str);
|
attribs = GetFileAttributes(str);
|
||||||
return attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY);
|
return attribs != INVALID_FILE_ATTRIBUTES && (attribs & FILE_ATTRIBUTE_DIRECTORY);
|
||||||
}
|
}
|
||||||
@ -349,7 +349,7 @@ cc_result Directory_Create(const cc_string* path) {
|
|||||||
TCHAR str[NATIVE_STR_LEN];
|
TCHAR str[NATIVE_STR_LEN];
|
||||||
BOOL success;
|
BOOL success;
|
||||||
|
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf16(str, path);
|
||||||
success = CreateDirectory(str, NULL);
|
success = CreateDirectory(str, NULL);
|
||||||
return success ? 0 : GetLastError();
|
return success ? 0 : GetLastError();
|
||||||
}
|
}
|
||||||
@ -358,7 +358,7 @@ int File_Exists(const cc_string* path) {
|
|||||||
TCHAR str[NATIVE_STR_LEN];
|
TCHAR str[NATIVE_STR_LEN];
|
||||||
DWORD attribs;
|
DWORD attribs;
|
||||||
|
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf16(str, path);
|
||||||
attribs = GetFileAttributes(str);
|
attribs = GetFileAttributes(str);
|
||||||
return attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY);
|
return attribs != INVALID_FILE_ATTRIBUTES && !(attribs & FILE_ATTRIBUTE_DIRECTORY);
|
||||||
}
|
}
|
||||||
@ -375,7 +375,7 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall
|
|||||||
/* Need to append \* to search for files in directory */
|
/* Need to append \* to search for files in directory */
|
||||||
String_InitArray(path, pathBuffer);
|
String_InitArray(path, pathBuffer);
|
||||||
String_Format1(&path, "%s\\*", dirPath);
|
String_Format1(&path, "%s\\*", dirPath);
|
||||||
Platform_EncodeString(str, &path);
|
Platform_EncodeUtf16(str, &path);
|
||||||
|
|
||||||
find = FindFirstFile(str, &entry);
|
find = FindFirstFile(str, &entry);
|
||||||
if (find == INVALID_HANDLE_VALUE) return GetLastError();
|
if (find == INVALID_HANDLE_VALUE) return GetLastError();
|
||||||
@ -409,7 +409,7 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall
|
|||||||
|
|
||||||
static cc_result File_Do(cc_file* file, const cc_string* path, DWORD access, DWORD createMode) {
|
static cc_result File_Do(cc_file* file, const cc_string* path, DWORD access, DWORD createMode) {
|
||||||
TCHAR str[NATIVE_STR_LEN];
|
TCHAR str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf16(str, path);
|
||||||
*file = CreateFile(str, access, FILE_SHARE_READ, NULL, createMode, 0, NULL);
|
*file = CreateFile(str, access, FILE_SHARE_READ, NULL, createMode, 0, NULL);
|
||||||
return *file != INVALID_HANDLE_VALUE ? 0 : GetLastError();
|
return *file != INVALID_HANDLE_VALUE ? 0 : GetLastError();
|
||||||
}
|
}
|
||||||
@ -457,13 +457,13 @@ cc_result File_Length(cc_file file, cc_uint32* len) {
|
|||||||
int Directory_Exists(const cc_string* path) {
|
int Directory_Exists(const cc_string* path) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf8(str, path);
|
||||||
return stat(str, &sb) == 0 && S_ISDIR(sb.st_mode);
|
return stat(str, &sb) == 0 && S_ISDIR(sb.st_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_result Directory_Create(const cc_string* path) {
|
cc_result Directory_Create(const cc_string* path) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf8(str, path);
|
||||||
/* read/write/search permissions for owner and group, and with read/search permissions for others. */
|
/* read/write/search permissions for owner and group, and with read/search permissions for others. */
|
||||||
/* TODO: Is the default mode in all cases */
|
/* TODO: Is the default mode in all cases */
|
||||||
return mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1 ? errno : 0;
|
return mkdir(str, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) == -1 ? errno : 0;
|
||||||
@ -472,7 +472,7 @@ cc_result Directory_Create(const cc_string* path) {
|
|||||||
int File_Exists(const cc_string* path) {
|
int File_Exists(const cc_string* path) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf8(str, path);
|
||||||
return stat(str, &sb) == 0 && S_ISREG(sb.st_mode);
|
return stat(str, &sb) == 0 && S_ISREG(sb.st_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -484,7 +484,7 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall
|
|||||||
char* src;
|
char* src;
|
||||||
int len, res;
|
int len, res;
|
||||||
|
|
||||||
Platform_EncodeString(str, dirPath);
|
Platform_EncodeUtf8(str, dirPath);
|
||||||
dirPtr = opendir(str);
|
dirPtr = opendir(str);
|
||||||
if (!dirPtr) return errno;
|
if (!dirPtr) return errno;
|
||||||
|
|
||||||
@ -522,7 +522,7 @@ cc_result Directory_Enum(const cc_string* dirPath, void* obj, Directory_EnumCall
|
|||||||
|
|
||||||
static cc_result File_Do(cc_file* file, const cc_string* path, int mode) {
|
static cc_result File_Do(cc_file* file, const cc_string* path, int mode) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf8(str, path);
|
||||||
*file = open(str, mode, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
*file = open(str, mode, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
|
||||||
return *file == -1 ? errno : 0;
|
return *file == -1 ? errno : 0;
|
||||||
}
|
}
|
||||||
@ -1057,14 +1057,14 @@ cc_result Process_StartGame(const cc_string* args) {
|
|||||||
|
|
||||||
String_InitArray(argv, argvBuffer);
|
String_InitArray(argv, argvBuffer);
|
||||||
String_Format1(&argv, "ClassiCube.exe %s", args);
|
String_Format1(&argv, "ClassiCube.exe %s", args);
|
||||||
Platform_EncodeString(raw, &argv);
|
Platform_EncodeUtf16(raw, &argv);
|
||||||
return Process_RawStart(path, raw);
|
return Process_RawStart(path, raw);
|
||||||
}
|
}
|
||||||
void Process_Exit(cc_result code) { ExitProcess(code); }
|
void Process_Exit(cc_result code) { ExitProcess(code); }
|
||||||
|
|
||||||
void Process_StartOpen(const cc_string* args) {
|
void Process_StartOpen(const cc_string* args) {
|
||||||
TCHAR str[NATIVE_STR_LEN];
|
TCHAR str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, args);
|
Platform_EncodeUtf16(str, args);
|
||||||
ShellExecute(NULL, NULL, str, NULL, NULL, SW_SHOWNORMAL);
|
ShellExecute(NULL, NULL, str, NULL, NULL, SW_SHOWNORMAL);
|
||||||
}
|
}
|
||||||
#elif defined CC_BUILD_WEB
|
#elif defined CC_BUILD_WEB
|
||||||
@ -1073,7 +1073,7 @@ void Process_Exit(cc_result code) { exit(code); }
|
|||||||
|
|
||||||
void Process_StartOpen(const cc_string* args) {
|
void Process_StartOpen(const cc_string* args) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, args);
|
Platform_EncodeUtf8(str, args);
|
||||||
EM_ASM_({ window.open(UTF8ToString($0)); }, str);
|
EM_ASM_({ window.open(UTF8ToString($0)); }, str);
|
||||||
}
|
}
|
||||||
#elif defined CC_BUILD_ANDROID
|
#elif defined CC_BUILD_ANDROID
|
||||||
@ -1116,7 +1116,7 @@ cc_result Process_StartGame(const cc_string* args) {
|
|||||||
if (res) return res;
|
if (res) return res;
|
||||||
path[len] = '\0';
|
path[len] = '\0';
|
||||||
|
|
||||||
Platform_EncodeString(raw, args);
|
Platform_EncodeUtf8(raw, args);
|
||||||
argv[0] = path; argv[1] = raw;
|
argv[0] = path; argv[1] = raw;
|
||||||
|
|
||||||
/* need to null-terminate multiple arguments */
|
/* need to null-terminate multiple arguments */
|
||||||
@ -1142,7 +1142,7 @@ void Process_StartOpen(const cc_string* args) {
|
|||||||
CFURLRef urlCF;
|
CFURLRef urlCF;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = Platform_EncodeString(str, args);
|
len = Platform_EncodeUtf8(str, args);
|
||||||
urlCF = CFURLCreateWithBytes(kCFAllocatorDefault, str, len, kCFStringEncodingUTF8, NULL);
|
urlCF = CFURLCreateWithBytes(kCFAllocatorDefault, str, len, kCFStringEncodingUTF8, NULL);
|
||||||
LSOpenCFURLRef(urlCF, NULL);
|
LSOpenCFURLRef(urlCF, NULL);
|
||||||
CFRelease(urlCF);
|
CFRelease(urlCF);
|
||||||
@ -1151,7 +1151,7 @@ void Process_StartOpen(const cc_string* args) {
|
|||||||
void Process_StartOpen(const cc_string* args) {
|
void Process_StartOpen(const cc_string* args) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
char* cmd[3];
|
char* cmd[3];
|
||||||
Platform_EncodeString(str, args);
|
Platform_EncodeUtf8(str, args);
|
||||||
|
|
||||||
cmd[0] = "open"; cmd[1] = str; cmd[2] = NULL;
|
cmd[0] = "open"; cmd[1] = str; cmd[2] = NULL;
|
||||||
Process_RawStart("open", cmd);
|
Process_RawStart("open", cmd);
|
||||||
@ -1160,7 +1160,7 @@ void Process_StartOpen(const cc_string* args) {
|
|||||||
void Process_StartOpen(const cc_string* args) {
|
void Process_StartOpen(const cc_string* args) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
char* cmd[3];
|
char* cmd[3];
|
||||||
Platform_EncodeString(str, args);
|
Platform_EncodeUtf8(str, args);
|
||||||
|
|
||||||
/* TODO: Can xdg-open be used on original Solaris, or is it just an OpenIndiana thing */
|
/* TODO: Can xdg-open be used on original Solaris, or is it just an OpenIndiana thing */
|
||||||
cmd[0] = "xdg-open"; cmd[1] = str; cmd[2] = NULL;
|
cmd[0] = "xdg-open"; cmd[1] = str; cmd[2] = NULL;
|
||||||
@ -1439,7 +1439,7 @@ const cc_string DynamicLib_Ext = String_FromConst(".dll");
|
|||||||
|
|
||||||
void* DynamicLib_Load2(const cc_string* path) {
|
void* DynamicLib_Load2(const cc_string* path) {
|
||||||
TCHAR str[NATIVE_STR_LEN];
|
TCHAR str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf16(str, path);
|
||||||
return LoadLibrary(str);
|
return LoadLibrary(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1463,7 +1463,7 @@ const cc_string DynamicLib_Ext = String_FromConst(".dylib");
|
|||||||
|
|
||||||
void* DynamicLib_Load2(const cc_string* path) {
|
void* DynamicLib_Load2(const cc_string* path) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf8(str, path);
|
||||||
return NSAddImage(str, NSADDIMAGE_OPTION_WITH_SEARCHING |
|
return NSAddImage(str, NSADDIMAGE_OPTION_WITH_SEARCHING |
|
||||||
NSADDIMAGE_OPTION_RETURN_ON_ERROR);
|
NSADDIMAGE_OPTION_RETURN_ON_ERROR);
|
||||||
}
|
}
|
||||||
@ -1505,7 +1505,7 @@ const cc_string DynamicLib_Ext = String_FromConst(".so");
|
|||||||
|
|
||||||
void* DynamicLib_Load2(const cc_string* path) {
|
void* DynamicLib_Load2(const cc_string* path) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, path);
|
Platform_EncodeUtf8(str, path);
|
||||||
return dlopen(str, RTLD_NOW);
|
return dlopen(str, RTLD_NOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1547,7 +1547,7 @@ cc_bool DynamicLib_GetAll(void* lib, const struct DynamicLibSym* syms, int count
|
|||||||
*--------------------------------------------------------Platform---------------------------------------------------------*
|
*--------------------------------------------------------Platform---------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
#if defined CC_BUILD_WIN
|
#if defined CC_BUILD_WIN
|
||||||
int Platform_EncodeString(void* data, const cc_string* src) {
|
int Platform_EncodeUtf16(void* data, const cc_string* src) {
|
||||||
TCHAR* dst = (TCHAR*)data;
|
TCHAR* dst = (TCHAR*)data;
|
||||||
int i;
|
int i;
|
||||||
if (src->length > FILENAME_SIZE) Logger_Abort("String too long to expand");
|
if (src->length > FILENAME_SIZE) Logger_Abort("String too long to expand");
|
||||||
@ -1631,7 +1631,7 @@ cc_bool Platform_DescribeError(cc_result res, cc_string* dst) {
|
|||||||
return Platform_DescribeErrorExt(res, dst, NULL);
|
return Platform_DescribeErrorExt(res, dst, NULL);
|
||||||
}
|
}
|
||||||
#elif defined CC_BUILD_POSIX
|
#elif defined CC_BUILD_POSIX
|
||||||
int Platform_EncodeString(void* data, const cc_string* src) {
|
int Platform_EncodeUtf8(void* data, const cc_string* src) {
|
||||||
cc_uint8* dst = (cc_uint8*)data;
|
cc_uint8* dst = (cc_uint8*)data;
|
||||||
cc_uint8* cur;
|
cc_uint8* cur;
|
||||||
int i, len = 0;
|
int i, len = 0;
|
||||||
|
@ -30,10 +30,15 @@ extern const cc_result ReturnCode_FileNotFound;
|
|||||||
extern const cc_result ReturnCode_SocketInProgess;
|
extern const cc_result ReturnCode_SocketInProgess;
|
||||||
extern const cc_result ReturnCode_SocketWouldBlock;
|
extern const cc_result ReturnCode_SocketWouldBlock;
|
||||||
|
|
||||||
/* Encodes a string in platform specific format. (e.g. unicode on windows, UTF8 on linux) */
|
#ifdef CC_BUILD_WIN
|
||||||
/* NOTE: Only useful for platform specific function calls - do NOT try to interpret the data. */
|
/* Encodes a string in UTF16 format, also null terminating the string. */
|
||||||
/* Returns the number of bytes written, excluding trailing NULL terminator. */
|
/* Returns the number of bytes written, excluding trailing NULL terminator. */
|
||||||
int Platform_EncodeString(void* data, const cc_string* src);
|
int Platform_EncodeUtf16(void* data, const cc_string* src);
|
||||||
|
#else
|
||||||
|
/* Encodes a string in UTF8 format, also null terminating the string. */
|
||||||
|
/* Returns the number of bytes written, excluding trailing NULL terminator. */
|
||||||
|
int Platform_EncodeUtf8(void* data, const cc_string* src);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Initialises the platform specific state. */
|
/* Initialises the platform specific state. */
|
||||||
void Platform_Init(void);
|
void Platform_Init(void);
|
||||||
|
24
src/Window.c
24
src/Window.c
@ -158,7 +158,7 @@ void Window_Create(int width, int height) {
|
|||||||
|
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, title);
|
Platform_EncodeUtf8(str, title);
|
||||||
SDL_SetWindowTitle(win_handle, str);
|
SDL_SetWindowTitle(win_handle, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ void Clipboard_GetText(cc_string* value) {
|
|||||||
|
|
||||||
void Clipboard_SetText(const cc_string* value) {
|
void Clipboard_SetText(const cc_string* value) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, value);
|
Platform_EncodeUtf8(str, value);
|
||||||
SDL_SetClipboardText(str);
|
SDL_SetClipboardText(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -743,7 +743,7 @@ void Window_Create(int width, int height) {
|
|||||||
|
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
TCHAR str[NATIVE_STR_LEN];
|
TCHAR str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, title);
|
Platform_EncodeUtf16(str, title);
|
||||||
SetWindowText(win_handle, str);
|
SetWindowText(win_handle, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1310,7 +1310,7 @@ void Window_Create(int width, int height) {
|
|||||||
|
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, title);
|
Platform_EncodeUtf8(str, title);
|
||||||
XStoreName(win_display, win_handle, str);
|
XStoreName(win_display, win_handle, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1611,7 +1611,7 @@ void Window_ProcessEvents(void) {
|
|||||||
if (e.xselectionrequest.selection == xa_clipboard && e.xselectionrequest.target == xa_utf8_string && clipboard_copy_text.length) {
|
if (e.xselectionrequest.selection == xa_clipboard && e.xselectionrequest.target == xa_utf8_string && clipboard_copy_text.length) {
|
||||||
reply.xselection.property = Window_GetSelectionProperty(&e);
|
reply.xselection.property = Window_GetSelectionProperty(&e);
|
||||||
char str[800];
|
char str[800];
|
||||||
int len = Platform_EncodeString(str, &clipboard_copy_text);
|
int len = Platform_EncodeUtf8(str, &clipboard_copy_text);
|
||||||
|
|
||||||
XChangeProperty(win_display, reply.xselection.requestor, reply.xselection.property, xa_utf8_string, 8,
|
XChangeProperty(win_display, reply.xselection.requestor, reply.xselection.property, xa_utf8_string, 8,
|
||||||
PropModeReplace, (unsigned char*)str, len);
|
PropModeReplace, (unsigned char*)str, len);
|
||||||
@ -2156,7 +2156,7 @@ void Clipboard_SetText(const cc_string* value) {
|
|||||||
if (err) Logger_Abort2(err, "Clearing Pasteboard");
|
if (err) Logger_Abort2(err, "Clearing Pasteboard");
|
||||||
PasteboardSynchronize(pbRef);
|
PasteboardSynchronize(pbRef);
|
||||||
|
|
||||||
len = Platform_EncodeString(str, value);
|
len = Platform_EncodeUtf8(str, value);
|
||||||
cfData = CFDataCreate(NULL, str, len);
|
cfData = CFDataCreate(NULL, str, len);
|
||||||
if (!cfData) Logger_Abort("CFDataCreate() returned null pointer");
|
if (!cfData) Logger_Abort("CFDataCreate() returned null pointer");
|
||||||
|
|
||||||
@ -2553,7 +2553,7 @@ void Window_SetTitle(const cc_string* title) {
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* TODO: This leaks memory, old title isn't released */
|
/* TODO: This leaks memory, old title isn't released */
|
||||||
len = Platform_EncodeString(str, title);
|
len = Platform_EncodeUtf8(str, title);
|
||||||
titleCF = CFStringCreateWithBytes(kCFAllocatorDefault, str, len, kCFStringEncodingUTF8, false);
|
titleCF = CFStringCreateWithBytes(kCFAllocatorDefault, str, len, kCFStringEncodingUTF8, false);
|
||||||
SetWindowTitleWithCFString(win_handle, titleCF);
|
SetWindowTitleWithCFString(win_handle, titleCF);
|
||||||
}
|
}
|
||||||
@ -2932,7 +2932,7 @@ void Window_SetTitle(const cc_string* title) {
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
/* TODO: This leaks memory, old title isn't released */
|
/* TODO: This leaks memory, old title isn't released */
|
||||||
len = Platform_EncodeString(str, title);
|
len = Platform_EncodeUtf8(str, title);
|
||||||
titleCF = CFStringCreateWithBytes(kCFAllocatorDefault, str, len, kCFStringEncodingUTF8, false);
|
titleCF = CFStringCreateWithBytes(kCFAllocatorDefault, str, len, kCFStringEncodingUTF8, false);
|
||||||
objc_msgSend(winHandle, sel_registerName("setTitle:"), titleCF);
|
objc_msgSend(winHandle, sel_registerName("setTitle:"), titleCF);
|
||||||
}
|
}
|
||||||
@ -3593,7 +3593,7 @@ void Window_Create(int width, int height) {
|
|||||||
|
|
||||||
void Window_SetTitle(const cc_string* title) {
|
void Window_SetTitle(const cc_string* title) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, title);
|
Platform_EncodeUtf8(str, title);
|
||||||
EM_ASM_({ document.title = UTF8ToString($0); }, str);
|
EM_ASM_({ document.title = UTF8ToString($0); }, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3613,7 +3613,7 @@ EMSCRIPTEN_KEEPALIVE void Window_GotClipboardText(char* src) {
|
|||||||
void Clipboard_GetText(cc_string* value) { }
|
void Clipboard_GetText(cc_string* value) { }
|
||||||
void Clipboard_SetText(const cc_string* value) {
|
void Clipboard_SetText(const cc_string* value) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
Platform_EncodeString(str, value);
|
Platform_EncodeUtf8(str, value);
|
||||||
|
|
||||||
/* For IE11, use window.clipboardData to set the clipboard */
|
/* For IE11, use window.clipboardData to set the clipboard */
|
||||||
/* For other browsers, instead use the window.copy events */
|
/* For other browsers, instead use the window.copy events */
|
||||||
@ -3801,7 +3801,7 @@ void Window_OpenKeyboard(const cc_string* text, int type) {
|
|||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
keyboardOpen = true;
|
keyboardOpen = true;
|
||||||
if (!Input_TouchMode) return;
|
if (!Input_TouchMode) return;
|
||||||
Platform_EncodeString(str, text);
|
Platform_EncodeUtf8(str, text);
|
||||||
Platform_LogConst("OPEN SESAME");
|
Platform_LogConst("OPEN SESAME");
|
||||||
|
|
||||||
EM_ASM_({
|
EM_ASM_({
|
||||||
@ -3836,7 +3836,7 @@ void Window_OpenKeyboard(const cc_string* text, int type) {
|
|||||||
void Window_SetKeyboardText(const cc_string* text) {
|
void Window_SetKeyboardText(const cc_string* text) {
|
||||||
char str[NATIVE_STR_LEN];
|
char str[NATIVE_STR_LEN];
|
||||||
if (!Input_TouchMode) return;
|
if (!Input_TouchMode) return;
|
||||||
Platform_EncodeString(str, text);
|
Platform_EncodeUtf8(str, text);
|
||||||
|
|
||||||
EM_ASM_({
|
EM_ASM_({
|
||||||
if (!window.cc_inputElem) return;
|
if (!window.cc_inputElem) return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user