You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-17 14:11:06 +00:00
Add methods to decode/encode multibyte encodings.
This commit is contained in:
committed by
Pāvels Nadtočajevs
parent
b13c96b097
commit
48bfe13e4f
@@ -35,6 +35,21 @@
|
||||
#include "core/os/os.h"
|
||||
#include "drivers/unix/ip_unix.h"
|
||||
|
||||
#ifdef __GLIBC__
|
||||
#include <iconv.h>
|
||||
#include <langinfo.h>
|
||||
#define gd_iconv_t iconv_t
|
||||
#define gd_iconv_open iconv_open
|
||||
#define gd_iconv iconv
|
||||
#define gd_iconv_close iconv_close
|
||||
#else
|
||||
typedef void *gd_iconv_t;
|
||||
typedef gd_iconv_t (*PIConvOpen)(const char *, const char *);
|
||||
typedef size_t (*PIConv)(gd_iconv_t, char **, size_t *, char **, size_t *);
|
||||
typedef int (*PIConvClose)(gd_iconv_t);
|
||||
typedef const char *(*PIConvLocaleCharset)(void);
|
||||
#endif
|
||||
|
||||
class OS_Unix : public OS {
|
||||
struct ProcessInfo {
|
||||
mutable bool is_running = true;
|
||||
@@ -43,6 +58,19 @@ class OS_Unix : public OS {
|
||||
HashMap<ProcessID, ProcessInfo> *process_map = nullptr;
|
||||
Mutex process_map_mutex;
|
||||
|
||||
#ifdef __GLIBC__
|
||||
bool _iconv_ok = true;
|
||||
#else
|
||||
bool _iconv_ok = false;
|
||||
|
||||
PIConvOpen gd_iconv_open = nullptr;
|
||||
PIConv gd_iconv = nullptr;
|
||||
PIConvClose gd_iconv_close = nullptr;
|
||||
PIConvLocaleCharset gd_locale_charset = nullptr;
|
||||
|
||||
void _load_iconv();
|
||||
#endif
|
||||
|
||||
protected:
|
||||
// UNIX only handles the core functions.
|
||||
// inheriting platforms under unix (eg. X11) should handle the rest
|
||||
@@ -87,6 +115,9 @@ public:
|
||||
|
||||
virtual Dictionary get_memory_info() const override;
|
||||
|
||||
virtual String multibyte_to_string(const String &p_encoding, const PackedByteArray &p_array) const override;
|
||||
virtual PackedByteArray string_to_multibyte(const String &p_encoding, const String &p_string) const override;
|
||||
|
||||
virtual Error execute(const String &p_path, const List<String> &p_arguments, String *r_pipe = nullptr, int *r_exitcode = nullptr, bool read_stderr = false, Mutex *p_pipe_mutex = nullptr, bool p_open_console = false) override;
|
||||
virtual Dictionary execute_with_pipe(const String &p_path, const List<String> &p_arguments, bool p_blocking = true) override;
|
||||
virtual Error create_process(const String &p_path, const List<String> &p_arguments, ProcessID *r_child_id = nullptr, bool p_open_console = false) override;
|
||||
|
||||
Reference in New Issue
Block a user