COMMON: Rewrite Encoder and drop dependency on iconv (#2586)
Different platforms have different levels of support of encodings and often have slight variations. We already have tables for most encoding with only CJK missing. Full transcoding inclusion allows us to get reliable encoding results independently of platform. The biggest con is the need for external tables encoding.dat. It removes a duplicate table for korean in graphics/korfont.cpp
This commit is contained in:
parent
228806a158
commit
68a9136e4d
74 changed files with 40828 additions and 2997 deletions
|
@ -433,6 +433,7 @@ endif
|
||||||
ifdef ENABLE_MYST3
|
ifdef ENABLE_MYST3
|
||||||
DIST_FILES_ENGINEDATA+=myst3.dat
|
DIST_FILES_ENGINEDATA+=myst3.dat
|
||||||
endif
|
endif
|
||||||
|
DIST_FILES_ENGINEDATA+=encoding.dat
|
||||||
DIST_FILES_ENGINEDATA:=$(addprefix $(srcdir)/dists/engine-data/,$(DIST_FILES_ENGINEDATA))
|
DIST_FILES_ENGINEDATA:=$(addprefix $(srcdir)/dists/engine-data/,$(DIST_FILES_ENGINEDATA))
|
||||||
|
|
||||||
# pred.dic is currently only used for the AGI engine
|
# pred.dic is currently only used for the AGI engine
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include "backends/dialogs/gtk/gtk-dialogs.h"
|
#include "backends/dialogs/gtk/gtk-dialogs.h"
|
||||||
|
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "common/encoding.h"
|
|
||||||
#include "common/translation.h"
|
#include "common/translation.h"
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
|
|
@ -67,7 +67,6 @@
|
||||||
#include "backends/platform/sdl/win32/win32-window.h"
|
#include "backends/platform/sdl/win32/win32-window.h"
|
||||||
|
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "common/encoding.h"
|
|
||||||
#include "common/translation.h"
|
#include "common/translation.h"
|
||||||
|
|
||||||
Win32DialogManager::Win32DialogManager(SdlWindow_Win32 *window) : _window(window) {
|
Win32DialogManager::Win32DialogManager(SdlWindow_Win32 *window) : _window(window) {
|
||||||
|
@ -131,11 +130,11 @@ Common::DialogManager::DialogResult Win32DialogManager::showFileBrowser(const Co
|
||||||
hr = dialog->SetOptions(dwOptions);
|
hr = dialog->SetOptions(dwOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
LPWSTR dialogTitle = (LPWSTR)Common::Encoding::convert("UTF-16", title);
|
LPWSTR dialogTitle = (LPWSTR)title.encodeUTF16Native();
|
||||||
hr = dialog->SetTitle(dialogTitle);
|
hr = dialog->SetTitle(dialogTitle);
|
||||||
free(dialogTitle);
|
free(dialogTitle);
|
||||||
|
|
||||||
LPWSTR okTitle = (LPWSTR)Common::Encoding::convert("UTF-16", _("Choose"));
|
LPWSTR okTitle = (LPWSTR)_("Choose").encodeUTF16Native();
|
||||||
hr = dialog->SetOkButtonLabel(okTitle);
|
hr = dialog->SetOkButtonLabel(okTitle);
|
||||||
free(okTitle);
|
free(okTitle);
|
||||||
|
|
||||||
|
|
|
@ -38,22 +38,8 @@
|
||||||
#define GAMECONTROLLERDB_FILE "gamecontrollerdb.txt"
|
#define GAMECONTROLLERDB_FILE "gamecontrollerdb.txt"
|
||||||
|
|
||||||
static uint32 convUTF8ToUTF32(const char *src) {
|
static uint32 convUTF8ToUTF32(const char *src) {
|
||||||
uint32 utf32 = 0;
|
Common::U32String u32(src);
|
||||||
|
return u32[0];
|
||||||
char *dst = SDL_iconv_string(
|
|
||||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
|
||||||
"UTF-32BE",
|
|
||||||
#else
|
|
||||||
"UTF-32LE",
|
|
||||||
#endif
|
|
||||||
"UTF-8", src, SDL_strlen(src) + 1);
|
|
||||||
|
|
||||||
if (dst) {
|
|
||||||
utf32 = *((uint32 *)dst);
|
|
||||||
SDL_free(dst);
|
|
||||||
}
|
|
||||||
|
|
||||||
return utf32;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SdlEventSource::loadGameControllerMappingFile() {
|
void SdlEventSource::loadGameControllerMappingFile() {
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "common/file.h"
|
#include "common/file.h"
|
||||||
#include "common/translation.h"
|
#include "common/translation.h"
|
||||||
#include "common/unzip.h"
|
#include "common/unzip.h"
|
||||||
#include "common/encoding.h"
|
|
||||||
|
|
||||||
namespace Networking {
|
namespace Networking {
|
||||||
|
|
||||||
|
|
|
@ -666,8 +666,4 @@ Common::String OSystem_Android::getSystemProperty(const char *name) const {
|
||||||
return Common::String(value, len);
|
return Common::String(value, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OSystem_Android::convertEncoding(const char *to, const char *from, const char *string, size_t length) {
|
|
||||||
return JNI::convertEncoding(to, from, string, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -136,7 +136,6 @@ public:
|
||||||
virtual bool setTextInClipboard(const Common::U32String &text) override;
|
virtual bool setTextInClipboard(const Common::U32String &text) override;
|
||||||
virtual bool isConnectionLimited() override;
|
virtual bool isConnectionLimited() override;
|
||||||
virtual Common::String getSystemLanguage() const override;
|
virtual Common::String getSystemLanguage() const override;
|
||||||
virtual char *convertEncoding(const char *to, const char *from, const char *string, size_t length) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,7 +45,6 @@
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "common/error.h"
|
#include "common/error.h"
|
||||||
#include "common/textconsole.h"
|
#include "common/textconsole.h"
|
||||||
#include "common/encoding.h"
|
|
||||||
#include "engines/engine.h"
|
#include "engines/engine.h"
|
||||||
|
|
||||||
#include "backends/platform/android/android.h"
|
#include "backends/platform/android/android.h"
|
||||||
|
@ -86,7 +85,6 @@ jmethodID JNI::_MID_setWindowCaption = 0;
|
||||||
jmethodID JNI::_MID_showVirtualKeyboard = 0;
|
jmethodID JNI::_MID_showVirtualKeyboard = 0;
|
||||||
jmethodID JNI::_MID_showKeyboardControl = 0;
|
jmethodID JNI::_MID_showKeyboardControl = 0;
|
||||||
jmethodID JNI::_MID_getSysArchives = 0;
|
jmethodID JNI::_MID_getSysArchives = 0;
|
||||||
jmethodID JNI::_MID_convertEncoding = 0;
|
|
||||||
jmethodID JNI::_MID_getAllStorageLocations = 0;
|
jmethodID JNI::_MID_getAllStorageLocations = 0;
|
||||||
jmethodID JNI::_MID_initSurface = 0;
|
jmethodID JNI::_MID_initSurface = 0;
|
||||||
jmethodID JNI::_MID_deinitSurface = 0;
|
jmethodID JNI::_MID_deinitSurface = 0;
|
||||||
|
@ -236,7 +234,7 @@ void JNI::displayMessageOnOSD(const Common::U32String &msg) {
|
||||||
// called from common/osd_message_queue, method: OSDMessageQueue::pollEvent()
|
// called from common/osd_message_queue, method: OSDMessageQueue::pollEvent()
|
||||||
JNIEnv *env = JNI::getEnv();
|
JNIEnv *env = JNI::getEnv();
|
||||||
|
|
||||||
jstring java_msg = convertToJString(env, msg.encode(), "UTF-8");
|
jstring java_msg = convertToJString(env, msg);
|
||||||
if (java_msg == nullptr) {
|
if (java_msg == nullptr) {
|
||||||
// Show a placeholder indicative of the translation error instead of silent failing
|
// Show a placeholder indicative of the translation error instead of silent failing
|
||||||
java_msg = env->NewStringUTF("?");
|
java_msg = env->NewStringUTF("?");
|
||||||
|
@ -303,15 +301,15 @@ Common::U32String JNI::getTextFromClipboard() {
|
||||||
return Common::U32String();
|
return Common::U32String();
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String text = convertFromJString(env, javaText, "UTF-8");
|
Common::U32String text = convertFromJString(env, javaText);
|
||||||
env->DeleteLocalRef(javaText);
|
env->DeleteLocalRef(javaText);
|
||||||
|
|
||||||
return text.decode();
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JNI::setTextInClipboard(const Common::U32String &text) {
|
bool JNI::setTextInClipboard(const Common::U32String &text) {
|
||||||
JNIEnv *env = JNI::getEnv();
|
JNIEnv *env = JNI::getEnv();
|
||||||
jstring javaText = convertToJString(env, text.encode(), "UTF-8");
|
jstring javaText = convertToJString(env, text);
|
||||||
|
|
||||||
bool success = env->CallBooleanMethod(_jobj, _MID_setTextInClipboard, javaText);
|
bool success = env->CallBooleanMethod(_jobj, _MID_setTextInClipboard, javaText);
|
||||||
|
|
||||||
|
@ -344,7 +342,7 @@ bool JNI::isConnectionLimited() {
|
||||||
|
|
||||||
void JNI::setWindowCaption(const Common::String &caption) {
|
void JNI::setWindowCaption(const Common::String &caption) {
|
||||||
JNIEnv *env = JNI::getEnv();
|
JNIEnv *env = JNI::getEnv();
|
||||||
jstring java_caption = convertToJString(env, caption, "ISO-8859-1");
|
jstring java_caption = convertToJString(env, caption.decode(Common::kISO8859_1));
|
||||||
|
|
||||||
env->CallVoidMethod(_jobj, _MID_setWindowCaption, java_caption);
|
env->CallVoidMethod(_jobj, _MID_setWindowCaption, java_caption);
|
||||||
|
|
||||||
|
@ -428,36 +426,6 @@ void JNI::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
|
||||||
s.add("ASSET", _asset_archive, priority - 1, false);
|
s.add("ASSET", _asset_archive, priority - 1, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *JNI::convertEncoding(const char *to, const char *from, const char *string, size_t length) {
|
|
||||||
JNIEnv *env = JNI::getEnv();
|
|
||||||
|
|
||||||
jstring javaTo = env->NewStringUTF(to);
|
|
||||||
jstring javaFrom = env->NewStringUTF(from);
|
|
||||||
jbyteArray javaString = env->NewByteArray(length);
|
|
||||||
env->SetByteArrayRegion(javaString, 0, length, reinterpret_cast<const jbyte*>(string));
|
|
||||||
|
|
||||||
jbyteArray javaOut = (jbyteArray)env->CallObjectMethod(_jobj, _MID_convertEncoding, javaTo, javaFrom, javaString);
|
|
||||||
|
|
||||||
if (!javaOut || env->ExceptionCheck()) {
|
|
||||||
LOGE("Failed to convert text from %s to %s", from, to);
|
|
||||||
|
|
||||||
env->ExceptionDescribe();
|
|
||||||
env->ExceptionClear();
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
int outLength = env->GetArrayLength(javaOut);
|
|
||||||
char *buf = (char *)malloc(outLength + 1);
|
|
||||||
if (!buf)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
env->GetByteArrayRegion(javaOut, 0, outLength, reinterpret_cast<jbyte *>(buf));
|
|
||||||
buf[outLength] = 0;
|
|
||||||
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool JNI::initSurface() {
|
bool JNI::initSurface() {
|
||||||
JNIEnv *env = JNI::getEnv();
|
JNIEnv *env = JNI::getEnv();
|
||||||
|
|
||||||
|
@ -586,7 +554,6 @@ void JNI::create(JNIEnv *env, jobject self, jobject asset_manager,
|
||||||
FIND_METHOD(, showKeyboardControl, "(Z)V");
|
FIND_METHOD(, showKeyboardControl, "(Z)V");
|
||||||
FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;");
|
FIND_METHOD(, getSysArchives, "()[Ljava/lang/String;");
|
||||||
FIND_METHOD(, getAllStorageLocations, "()[Ljava/lang/String;");
|
FIND_METHOD(, getAllStorageLocations, "()[Ljava/lang/String;");
|
||||||
FIND_METHOD(, convertEncoding, "(Ljava/lang/String;Ljava/lang/String;[B)[B");
|
|
||||||
FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;");
|
FIND_METHOD(, initSurface, "()Ljavax/microedition/khronos/egl/EGLSurface;");
|
||||||
FIND_METHOD(, deinitSurface, "()V");
|
FIND_METHOD(, deinitSurface, "()V");
|
||||||
FIND_METHOD(, createDirectoryWithSAF, "(Ljava/lang/String;)Z");
|
FIND_METHOD(, createDirectoryWithSAF, "(Ljava/lang/String;)Z");
|
||||||
|
@ -752,29 +719,21 @@ void JNI::setPause(JNIEnv *env, jobject self, jboolean value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jstring JNI::convertToJString(JNIEnv *env, const Common::String &str, const Common::String &from) {
|
jstring JNI::convertToJString(JNIEnv *env, const Common::U32String &str) {
|
||||||
Common::Encoding converter("UTF-8", from.c_str());
|
uint len = 0;
|
||||||
char *utf8Str = converter.convert(str.c_str(), converter.stringLength(str.c_str(), from));
|
uint16 *u16str = str.encodeUTF16Native(&len);
|
||||||
if (utf8Str == nullptr)
|
jstring jstr = env->NewString(u16str, len);
|
||||||
return nullptr;
|
delete[] u16str;
|
||||||
|
|
||||||
jstring jstr = env->NewStringUTF(utf8Str);
|
|
||||||
free(utf8Str);
|
|
||||||
|
|
||||||
return jstr;
|
return jstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String JNI::convertFromJString(JNIEnv *env, const jstring &jstr, const Common::String &to) {
|
Common::U32String JNI::convertFromJString(JNIEnv *env, const jstring &jstr) {
|
||||||
const char *utf8Str = env->GetStringUTFChars(jstr, 0);
|
const uint16 *utf16Str = env->GetStringChars(jstr, 0);
|
||||||
if (!utf8Str)
|
uint jcount = env->GetStringLength(jstr);
|
||||||
return Common::String();
|
if (!utf16Str)
|
||||||
|
return Common::U32String();
|
||||||
Common::Encoding converter(to.c_str(), "UTF-8");
|
Common::U32String str = Common::U32String::decodeUTF16Native(utf16Str, jcount);
|
||||||
char *asciiStr = converter.convert(utf8Str, env->GetStringUTFLength(jstr));
|
env->ReleaseStringChars(jstr, utf16Str);
|
||||||
env->ReleaseStringUTFChars(jstr, utf8Str);
|
|
||||||
|
|
||||||
Common::String str(asciiStr);
|
|
||||||
free(asciiStr);
|
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
@ -830,7 +789,7 @@ bool JNI::createDirectoryWithSAF(const Common::String &dirPath) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String JNI::createFileWithSAF(const Common::String &filePath) {
|
Common::U32String JNI::createFileWithSAF(const Common::String &filePath) {
|
||||||
JNIEnv *env = JNI::getEnv();
|
JNIEnv *env = JNI::getEnv();
|
||||||
jstring javaFilePath = env->NewStringUTF(filePath.c_str());
|
jstring javaFilePath = env->NewStringUTF(filePath.c_str());
|
||||||
|
|
||||||
|
@ -845,7 +804,7 @@ Common::String JNI::createFileWithSAF(const Common::String &filePath) {
|
||||||
hackyFilenameJSTR = env->NewStringUTF("");
|
hackyFilenameJSTR = env->NewStringUTF("");
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String hackyFilenameStr = convertFromJString(env, hackyFilenameJSTR, "UTF-8");
|
Common::U32String hackyFilenameStr = convertFromJString(env, hackyFilenameJSTR);
|
||||||
|
|
||||||
//LOGD("JNI - _MID_createFileWithSAF returned %s", hackyFilenameStr.c_str());
|
//LOGD("JNI - _MID_createFileWithSAF returned %s", hackyFilenameStr.c_str());
|
||||||
env->DeleteLocalRef(hackyFilenameJSTR);
|
env->DeleteLocalRef(hackyFilenameJSTR);
|
||||||
|
|
|
@ -69,7 +69,6 @@ public:
|
||||||
static void showVirtualKeyboard(bool enable);
|
static void showVirtualKeyboard(bool enable);
|
||||||
static void showKeyboardControl(bool enable);
|
static void showKeyboardControl(bool enable);
|
||||||
static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
|
static void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
|
||||||
static char *convertEncoding(const char *to, const char *from, const char *string, size_t length);
|
|
||||||
|
|
||||||
static inline bool haveSurface();
|
static inline bool haveSurface();
|
||||||
static inline bool swapBuffers();
|
static inline bool swapBuffers();
|
||||||
|
@ -86,7 +85,7 @@ public:
|
||||||
static Common::Array<Common::String> getAllStorageLocations();
|
static Common::Array<Common::String> getAllStorageLocations();
|
||||||
|
|
||||||
static bool createDirectoryWithSAF(const Common::String &dirPath);
|
static bool createDirectoryWithSAF(const Common::String &dirPath);
|
||||||
static Common::String createFileWithSAF(const Common::String &filePath);
|
static Common::U32String createFileWithSAF(const Common::String &filePath);
|
||||||
static void closeFileWithSAF(const Common::String &hackyFilename);
|
static void closeFileWithSAF(const Common::String &hackyFilename);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -114,7 +113,6 @@ private:
|
||||||
static jmethodID _MID_showVirtualKeyboard;
|
static jmethodID _MID_showVirtualKeyboard;
|
||||||
static jmethodID _MID_showKeyboardControl;
|
static jmethodID _MID_showKeyboardControl;
|
||||||
static jmethodID _MID_getSysArchives;
|
static jmethodID _MID_getSysArchives;
|
||||||
static jmethodID _MID_convertEncoding;
|
|
||||||
static jmethodID _MID_getAllStorageLocations;
|
static jmethodID _MID_getAllStorageLocations;
|
||||||
static jmethodID _MID_initSurface;
|
static jmethodID _MID_initSurface;
|
||||||
static jmethodID _MID_deinitSurface;
|
static jmethodID _MID_deinitSurface;
|
||||||
|
@ -149,8 +147,8 @@ private:
|
||||||
int arg2, int arg3, int arg4, int arg5, int arg6);
|
int arg2, int arg3, int arg4, int arg5, int arg6);
|
||||||
static void setPause(JNIEnv *env, jobject self, jboolean value);
|
static void setPause(JNIEnv *env, jobject self, jboolean value);
|
||||||
|
|
||||||
static jstring convertToJString(JNIEnv *env, const Common::String &str, const Common::String &from);
|
static jstring convertToJString(JNIEnv *env, const Common::U32String &str);
|
||||||
static Common::String convertFromJString(JNIEnv *env, const jstring &jstr, const Common::String &to);
|
static Common::U32String convertFromJString(JNIEnv *env, const jstring &jstr);
|
||||||
|
|
||||||
static PauseToken _pauseToken;
|
static PauseToken _pauseToken;
|
||||||
};
|
};
|
||||||
|
|
|
@ -10,7 +10,6 @@ import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.SurfaceHolder;
|
import android.view.SurfaceHolder;
|
||||||
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
|
@ -68,7 +67,6 @@ public abstract class ScummVM implements SurfaceHolder.Callback, Runnable {
|
||||||
abstract protected void showVirtualKeyboard(boolean enable);
|
abstract protected void showVirtualKeyboard(boolean enable);
|
||||||
abstract protected void showKeyboardControl(boolean enable);
|
abstract protected void showKeyboardControl(boolean enable);
|
||||||
abstract protected String[] getSysArchives();
|
abstract protected String[] getSysArchives();
|
||||||
abstract protected byte[] convertEncoding(String to, String from, byte[] string) throws UnsupportedEncodingException;
|
|
||||||
abstract protected String[] getAllStorageLocations();
|
abstract protected String[] getAllStorageLocations();
|
||||||
abstract protected String[] getAllStorageLocationsNoPermissionRequest();
|
abstract protected String[] getAllStorageLocationsNoPermissionRequest();
|
||||||
abstract protected boolean createDirectoryWithSAF(String dirPath);
|
abstract protected boolean createDirectoryWithSAF(String dirPath);
|
||||||
|
|
|
@ -673,12 +673,6 @@ public class ScummVMActivity extends Activity implements OnKeyboardVisibilityLis
|
||||||
} else return new String[]{_actualScummVMDataDir.getPath()};
|
} else return new String[]{_actualScummVMDataDir.getPath()};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected byte[] convertEncoding(String to, String from, byte[] string) throws UnsupportedEncodingException {
|
|
||||||
String str = new String(string, from);
|
|
||||||
return str.getBytes(to);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getAllStorageLocations() {
|
protected String[] getAllStorageLocations() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||||
|
|
|
@ -581,8 +581,4 @@ Common::String OSystem_Android::getSystemProperty(const char *name) const {
|
||||||
return Common::String(value, len);
|
return Common::String(value, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OSystem_Android::convertEncoding(const char *to, const char *from, const char *string, size_t length) {
|
|
||||||
return JNI::convertEncoding(to, from, string, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -189,7 +189,6 @@ public:
|
||||||
virtual bool setTextInClipboard(const Common::U32String &text);
|
virtual bool setTextInClipboard(const Common::U32String &text);
|
||||||
virtual bool isConnectionLimited();
|
virtual bool isConnectionLimited();
|
||||||
virtual Common::String getSystemLanguage() const;
|
virtual Common::String getSystemLanguage() const;
|
||||||
virtual char *convertEncoding(const char *to, const char *from, const char *string, size_t length);
|
|
||||||
|
|
||||||
void updateEventScale(const GLESBaseTexture *tex);
|
void updateEventScale(const GLESBaseTexture *tex);
|
||||||
TouchControls* getTouchControls() { return &_touchControls; }
|
TouchControls* getTouchControls() { return &_touchControls; }
|
||||||
|
|
|
@ -65,7 +65,6 @@ public abstract class ResidualVM implements SurfaceHolder.Callback, Runnable {
|
||||||
abstract protected void showVirtualKeyboard(boolean enable);
|
abstract protected void showVirtualKeyboard(boolean enable);
|
||||||
abstract protected void showKeyboardControl(boolean enable);
|
abstract protected void showKeyboardControl(boolean enable);
|
||||||
abstract protected String[] getSysArchives();
|
abstract protected String[] getSysArchives();
|
||||||
abstract protected byte[] convertEncoding(String to, String from, byte[] string) throws UnsupportedEncodingException;
|
|
||||||
abstract protected String[] getAllStorageLocations();
|
abstract protected String[] getAllStorageLocations();
|
||||||
|
|
||||||
public ResidualVM(AssetManager asset_manager, SurfaceHolder holder) {
|
public ResidualVM(AssetManager asset_manager, SurfaceHolder holder) {
|
||||||
|
|
|
@ -228,12 +228,6 @@ public class ResidualVMActivity extends Activity {
|
||||||
return new String[0];
|
return new String[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected byte[] convertEncoding(String to, String from, byte[] string) throws UnsupportedEncodingException {
|
|
||||||
String str = new String(string, from);
|
|
||||||
return str.getBytes(to);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String[] getAllStorageLocations() {
|
protected String[] getAllStorageLocations() {
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
|
||||||
|
|
|
@ -83,6 +83,10 @@ public:
|
||||||
|
|
||||||
virtual void logMessage(LogMessageType::Type type, const char *message);
|
virtual void logMessage(LogMessageType::Type type, const char *message);
|
||||||
|
|
||||||
|
#ifdef NULL_DRIVER_USE_FOR_TEST
|
||||||
|
virtual void addSysArchivesToSearchSet(Common::SearchSet &s, int priority);
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef POSIX
|
#ifdef POSIX
|
||||||
timeval _startTime;
|
timeval _startTime;
|
||||||
|
@ -108,7 +112,7 @@ OSystem_NULL::OSystem_NULL() {
|
||||||
OSystem_NULL::~OSystem_NULL() {
|
OSystem_NULL::~OSystem_NULL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef POSIX
|
#if defined(POSIX) && !defined(NULL_DRIVER_USE_FOR_TEST)
|
||||||
static volatile bool intReceived = false;
|
static volatile bool intReceived = false;
|
||||||
|
|
||||||
static sighandler_t last_handler;
|
static sighandler_t last_handler;
|
||||||
|
@ -122,7 +126,8 @@ void intHandler(int dummy) {
|
||||||
void OSystem_NULL::initBackend() {
|
void OSystem_NULL::initBackend() {
|
||||||
#ifdef POSIX
|
#ifdef POSIX
|
||||||
gettimeofday(&_startTime, 0);
|
gettimeofday(&_startTime, 0);
|
||||||
|
#endif
|
||||||
|
#if defined(POSIX) && !defined(NULL_DRIVER_USE_FOR_TEST)
|
||||||
last_handler = signal(SIGINT, intHandler);
|
last_handler = signal(SIGINT, intHandler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -142,7 +147,7 @@ bool OSystem_NULL::pollEvent(Common::Event &event) {
|
||||||
((DefaultTimerManager *)getTimerManager())->checkTimers();
|
((DefaultTimerManager *)getTimerManager())->checkTimers();
|
||||||
((NullMixerManager *)_mixerManager)->update(1);
|
((NullMixerManager *)_mixerManager)->update(1);
|
||||||
|
|
||||||
#ifdef POSIX
|
#if defined(POSIX) && !defined(NULL_DRIVER_USE_FOR_TEST)
|
||||||
if (intReceived) {
|
if (intReceived) {
|
||||||
intReceived = false;
|
intReceived = false;
|
||||||
|
|
||||||
|
@ -214,6 +219,7 @@ OSystem *OSystem_NULL_create() {
|
||||||
return new OSystem_NULL();
|
return new OSystem_NULL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NULL_DRIVER_USE_FOR_TEST
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
g_system = OSystem_NULL_create();
|
g_system = OSystem_NULL_create();
|
||||||
assert(g_system);
|
assert(g_system);
|
||||||
|
@ -223,6 +229,16 @@ int main(int argc, char *argv[]) {
|
||||||
g_system->destroy();
|
g_system->destroy();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
void OSystem_NULL::addSysArchivesToSearchSet(Common::SearchSet &s, int priority) {
|
||||||
|
Common::String dataPath = "dists/engine-data";
|
||||||
|
Common::FSNode dataNode(dataPath);
|
||||||
|
s.add(dataPath, new Common::FSDirectory(dataNode, 4), priority);
|
||||||
|
}
|
||||||
|
void Common::install_null_g_system() {
|
||||||
|
g_system = OSystem_NULL_create();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#else /* USE_NULL_DRIVER */
|
#else /* USE_NULL_DRIVER */
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "gui/EventRecorder.h"
|
#include "gui/EventRecorder.h"
|
||||||
#include "common/taskbar.h"
|
#include "common/taskbar.h"
|
||||||
#include "common/textconsole.h"
|
#include "common/textconsole.h"
|
||||||
#include "common/encoding.h"
|
|
||||||
|
|
||||||
#ifdef USE_DISCORD
|
#ifdef USE_DISCORD
|
||||||
#include "backends/presence/discord/discord.h"
|
#include "backends/presence/discord/discord.h"
|
||||||
|
@ -892,49 +891,3 @@ void OSystem_SDL::setupGraphicsModes() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *OSystem_SDL::convertEncoding(const char *to, const char *from, const char *string, size_t length) {
|
|
||||||
#if SDL_VERSION_ATLEAST(1, 2, 10) && !defined(__MORPHOS__)
|
|
||||||
int zeroBytes = 1;
|
|
||||||
if (Common::String(from).hasPrefixIgnoreCase("utf-16"))
|
|
||||||
zeroBytes = 2;
|
|
||||||
else if (Common::String(from).hasPrefixIgnoreCase("utf-32"))
|
|
||||||
zeroBytes = 4;
|
|
||||||
|
|
||||||
char *result;
|
|
||||||
// SDL_iconv_string() takes char * instead of const char * as it's third parameter
|
|
||||||
// with some older versions of SDL.
|
|
||||||
#if SDL_VERSION_ATLEAST(2, 0, 0)
|
|
||||||
result = SDL_iconv_string(to, from, string, length + zeroBytes);
|
|
||||||
#else
|
|
||||||
char *stringCopy = (char *) calloc(sizeof(char), length + zeroBytes);
|
|
||||||
memcpy(stringCopy, string, length);
|
|
||||||
result = SDL_iconv_string(to, from, stringCopy, length + zeroBytes);
|
|
||||||
free(stringCopy);
|
|
||||||
#endif // SDL_VERSION_ATLEAST(2, 0, 0)
|
|
||||||
if (result == nullptr)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
// We need to copy the result, so that we can use SDL_free()
|
|
||||||
// on the string returned by SDL_iconv_string() and free()
|
|
||||||
// can then be used on the copyed and returned string.
|
|
||||||
// Sometimes free() and SDL_free() aren't compatible and
|
|
||||||
// using free() instead of SDL_free() can cause crashes.
|
|
||||||
size_t newLength = Common::Encoding::stringLength(result, to);
|
|
||||||
zeroBytes = 1;
|
|
||||||
if (Common::String(to).hasPrefixIgnoreCase("utf-16"))
|
|
||||||
zeroBytes = 2;
|
|
||||||
else if (Common::String(to).hasPrefixIgnoreCase("utf-32"))
|
|
||||||
zeroBytes = 4;
|
|
||||||
char *finalResult = (char *) malloc(newLength + zeroBytes);
|
|
||||||
if (!finalResult) {
|
|
||||||
warning("Could not allocate memory for encoding conversion");
|
|
||||||
SDL_free(result);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
memcpy(finalResult, result, newLength + zeroBytes);
|
|
||||||
SDL_free(result);
|
|
||||||
return finalResult;
|
|
||||||
#else
|
|
||||||
return BaseBackend::convertEncoding(to, from, string, length);
|
|
||||||
#endif // SDL_VERSION_ATLEAST(1, 2, 10)
|
|
||||||
}
|
|
||||||
|
|
|
@ -169,8 +169,6 @@ protected:
|
||||||
virtual bool setGraphicsMode(int mode, uint flags) override;
|
virtual bool setGraphicsMode(int mode, uint flags) override;
|
||||||
virtual int getGraphicsMode() const override;
|
virtual int getGraphicsMode() const override;
|
||||||
#endif
|
#endif
|
||||||
protected:
|
|
||||||
virtual char *convertEncoding(const char *to, const char *from, const char *string, size_t length) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,209 +0,0 @@
|
||||||
/* ScummVM - Graphic Adventure Engine
|
|
||||||
*
|
|
||||||
* ScummVM is the legal property of its developers, whose names
|
|
||||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
||||||
* file distributed with this source distribution.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef WIN32_CODEPAGE_H
|
|
||||||
#define WIN32_CODEPAGE_H
|
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
|
||||||
#include "common/str.h"
|
|
||||||
namespace Win32 {
|
|
||||||
struct CodePageDescription {
|
|
||||||
const char *name;
|
|
||||||
int id;
|
|
||||||
};
|
|
||||||
|
|
||||||
//For more info look at https://docs.microsoft.com/en-us/windows/win32/intl/code-page-identifiers
|
|
||||||
//If there is a different name for a codepage, just add another row.
|
|
||||||
const CodePageDescription g_cpDescriptions[] = {
|
|
||||||
{"ibm037", 37}, //IBM EBCDIC US-Canada
|
|
||||||
{"ibm437", 437}, //OEM United States
|
|
||||||
{"ibm500", 500}, //IBM EBCDIC International
|
|
||||||
{"asmo-708", 708}, //Arabic (ASMO 708)
|
|
||||||
{"arabic1", 709}, //Arabic (ASMO-449+, BCON V4)
|
|
||||||
{"arabic2", 710}, //Arabic - Transparent Arabic
|
|
||||||
{"dos-720", 720}, //Arabic (Transparent ASMO); Arabic (DOS)
|
|
||||||
{"ibm737", 737}, //OEM Greek (formerly 437G); Greek (DOS)
|
|
||||||
{"ibm775", 775}, //OEM Baltic; Baltic (DOS)
|
|
||||||
{"ibm850", 850}, //OEM Multilingual Latin 1; Western European (DOS)
|
|
||||||
{"cp850", 850}, //OEM Multilingual Latin 1; Western European (DOS)
|
|
||||||
{"ascii", 850}, //We have multiple choices for codepage for ascii, this is one of many that works
|
|
||||||
{"ibm852", 852}, //OEM Latin 2; Central European (DOS)
|
|
||||||
{"ibm855", 855}, //OEM Cyrillic (primarily Russian)
|
|
||||||
{"ibm857", 857}, //OEM Turkish; Turkish (DOS)
|
|
||||||
{"ibm00858", 858}, //OEM Multilingual Latin 1 + Euro symbol
|
|
||||||
{"ibm858", 858}, //OEM Multilingual Latin 1 + Euro symbol
|
|
||||||
{"ibm860", 860}, //OEM Portuguese; Portuguese (DOS)
|
|
||||||
{"ibm861", 861}, //OEM Icelandic; Icelandic (DOS)
|
|
||||||
{"dos-862", 862}, //OEM Hebrew; Hebrew (DOS)
|
|
||||||
{"ibm863", 863}, //OEM French Canadian; French Canadian (DOS)
|
|
||||||
{"ibm864", 864}, //OEM Arabic; Arabic (864)
|
|
||||||
{"ibm865", 865}, //OEM Nordic; Nordic (DOS)
|
|
||||||
{"cp866", 866}, //OEM Russian; Cyrillic (DOS)
|
|
||||||
{"ibm869", 869}, //OEM Modern Greek; Greek, Modern (DOS)
|
|
||||||
{"ibm870", 870}, //IBM EBCDIC Multilingual/ROECE (Latin 2); IBM EBCDIC Multilingual Latin 2
|
|
||||||
{"windows-874", 874}, //ANSI/OEM Thai (ISO 8859-11); Thai (Windows)
|
|
||||||
{"cp875", 875}, //IBM EBCDIC Greek Modern
|
|
||||||
{"shift_jis", 932}, //ANSI/OEM Japanese; Japanese (Shift-JIS)
|
|
||||||
{"cp932", 932}, //ANSI/OEM Japanese; Japanese (Shift-JIS)
|
|
||||||
{"gb2312", 936}, //ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312)
|
|
||||||
{"ks_c_5601-1987", 949}, //ANSI/OEM Korean (Unified Hangul Code)
|
|
||||||
{"cp949", 949}, //ANSI/OEM Korean (Unified Hangul Code)
|
|
||||||
{"uhc", 949}, //ANSI/OEM Korean (Unified Hangul Code)
|
|
||||||
{"big5", 950}, //ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5)
|
|
||||||
{"cp950", 950}, //ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5)
|
|
||||||
{"ibm1026", 1026}, //IBM EBCDIC Turkish (Latin 5)
|
|
||||||
{"ibm01047", 1047}, //IBM EBCDIC Latin 1/Open System
|
|
||||||
{"ibm01140", 1140}, //IBM EBCDIC US-Canada (037 + Euro symbol); IBM EBCDIC (US-Canada-Euro)
|
|
||||||
{"ibm01141", 1141}, //IBM EBCDIC Germany (20273 + Euro symbol); IBM EBCDIC (Germany-Euro)
|
|
||||||
{"ibm01142", 1142}, //IBM EBCDIC Denmark-Norway (20277 + Euro symbol); IBM EBCDIC (Denmark-Norway-Euro)
|
|
||||||
{"ibm01143", 1143}, //IBM EBCDIC Finland-Sweden (20278 + Euro symbol); IBM EBCDIC (Finland-Sweden-Euro)
|
|
||||||
{"ibm01144", 1144}, //IBM EBCDIC Italy (20280 + Euro symbol); IBM EBCDIC (Italy-Euro)
|
|
||||||
{"ibm01145", 1145}, //IBM EBCDIC Latin America-Spain (20284 + Euro symbol); IBM EBCDIC (Spain-Euro)
|
|
||||||
{"ibm01146", 1146}, //IBM EBCDIC United Kingdom (20285 + Euro symbol); IBM EBCDIC (UK-Euro)
|
|
||||||
{"ibm01147", 1147}, //IBM EBCDIC France (20297 + Euro symbol); IBM EBCDIC (France-Euro)
|
|
||||||
{"ibm01148", 1148}, //IBM EBCDIC International (500 + Euro symbol); IBM EBCDIC (International-Euro)
|
|
||||||
{"ibm01149", 1149}, //IBM EBCDIC Icelandic (20871 + Euro symbol); IBM EBCDIC (Icelandic-Euro)
|
|
||||||
{"utf-16", 1200}, //Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications
|
|
||||||
{"unicodefffe", 1201}, //Unicode UTF-16, big endian byte order; available only to managed applications
|
|
||||||
{"windows-1250", 1250}, //ANSI Central European; Central European (Windows)
|
|
||||||
{"windows-1251", 1251}, //ANSI Cyrillic; Cyrillic (Windows)
|
|
||||||
{"windows-1252", 1252}, //ANSI Latin 1; Western European (Windows)
|
|
||||||
{"windows-1253", 1253}, //ANSI Greek; Greek (Windows)
|
|
||||||
{"windows-1254", 1254}, //ANSI Turkish; Turkish (Windows)
|
|
||||||
{"windows-1255", 1255}, //ANSI Hebrew; Hebrew (Windows)
|
|
||||||
{"windows-1256", 1256}, //ANSI Arabic; Arabic (Windows)
|
|
||||||
{"windows-1257", 1257}, //ANSI Baltic; Baltic (Windows)
|
|
||||||
{"windows-1258", 1258}, //ANSI/OEM Vietnamese; Vietnamese (Windows)
|
|
||||||
{"johab", 1361}, //Korean (Johab)
|
|
||||||
{"macintosh", 10000}, //MAC Roman; Western European (Mac)
|
|
||||||
{"x-mac-japanese", 10001}, //Japanese (Mac)
|
|
||||||
{"x-mac-chinesetrad", 10002}, //MAC Traditional Chinese (Big5); Chinese Traditional (Mac)
|
|
||||||
{"x-mac-korean", 10003}, //Korean (Mac)
|
|
||||||
{"x-mac-arabic", 10004}, //Arabic (Mac)
|
|
||||||
{"x-mac-hebrew", 10005}, //Hebrew (Mac)
|
|
||||||
{"x-mac-greek", 10006}, //Greek (Mac)
|
|
||||||
{"x-mac-cyrillic", 10007}, //Cyrillic (Mac)
|
|
||||||
{"x-mac-chinesesimp", 10008}, //MAC Simplified Chinese (GB 2312); Chinese Simplified (Mac)
|
|
||||||
{"x-mac-romanian", 10010}, //Romanian (Mac)
|
|
||||||
{"x-mac-ukrainian", 10017}, //Ukrainian (Mac)
|
|
||||||
{"x-mac-thai", 10021}, //Thai (Mac)
|
|
||||||
{"x-mac-ce", 10029}, //MAC Latin 2; Central European (Mac)
|
|
||||||
{"x-mac-icelandic", 10079}, //Icelandic (Mac)
|
|
||||||
{"x-mac-turkish", 10081}, //Turkish (Mac)
|
|
||||||
{"x-mac-croatian", 10082}, //Croatian (Mac)
|
|
||||||
{"utf-32", 12000}, //Unicode UTF-32, little endian byte order; available only to managed applications
|
|
||||||
{"utf-32be", 12001}, //Unicode UTF-32, big endian byte order; available only to managed applications
|
|
||||||
{"x-chinese_cns", 20000}, //CNS Taiwan; Chinese Traditional (CNS)
|
|
||||||
{"x-cp20001", 20001}, //TCA Taiwan
|
|
||||||
{"x_chinese-eten", 20002}, //Eten Taiwan; Chinese Traditional (Eten)
|
|
||||||
{"x-cp20003", 20003}, //IBM5550 Taiwan
|
|
||||||
{"x-cp20004", 20004}, //TeleText Taiwan
|
|
||||||
{"x-cp20005", 20005}, //Wang Taiwan
|
|
||||||
{"x-ia5", 20105}, //IA5 (IRV International Alphabet No. 5, 7-bit); Western European (IA5)
|
|
||||||
{"x-ia5-german", 20106}, //IA5 German (7-bit)
|
|
||||||
{"x-ia5-swedish", 20107}, //IA5 Swedish (7-bit)
|
|
||||||
{"x-ia5-norwegian", 20108}, //IA5 Norwegian (7-bit)
|
|
||||||
{"us-ascii", 20127}, //US-ASCII (7-bit)
|
|
||||||
{"x-cp20261", 20261}, //T.61
|
|
||||||
{"x-cp20269", 20269}, //ISO 6937 Non-Spacing Accent
|
|
||||||
{"ibm273", 20273}, //IBM EBCDIC Germany
|
|
||||||
{"ibm277", 20277}, //IBM EBCDIC Denmark-Norway
|
|
||||||
{"ibm278", 20278}, //IBM EBCDIC Finland-Sweden
|
|
||||||
{"ibm280", 20280}, //IBM EBCDIC Italy
|
|
||||||
{"ibm284", 20284}, //IBM EBCDIC Latin America-Spain
|
|
||||||
{"ibm285", 20285}, //IBM EBCDIC United Kingdom
|
|
||||||
{"ibm290", 20290}, //IBM EBCDIC Japanese Katakana Extended
|
|
||||||
{"ibm297", 20297}, //IBM EBCDIC France
|
|
||||||
{"ibm420", 20420}, //IBM EBCDIC Arabic
|
|
||||||
{"ibm423", 20423}, //IBM EBCDIC Greek
|
|
||||||
{"ibm424", 20424}, //IBM EBCDIC Hebrew
|
|
||||||
{"x-ebcdic-koreanextended", 20833}, //IBM EBCDIC Korean Extended
|
|
||||||
{"ibm-thai", 20838}, //IBM EBCDIC Thai
|
|
||||||
{"koi8-r", 20866}, //Russian (KOI8-R); Cyrillic (KOI8-R)
|
|
||||||
{"ibm871", 20871}, //IBM EBCDIC Icelandic
|
|
||||||
{"ibm880", 20880}, //IBM EBCDIC Cyrillic Russian
|
|
||||||
{"ibm905", 20905}, //IBM EBCDIC Turkish
|
|
||||||
{"ibm00924", 20924}, //IBM EBCDIC Latin 1/Open System (1047 + Euro symbol)
|
|
||||||
{"euc-jp", 20932}, //Japanese (JIS 0208-1990 and 0212-1990)
|
|
||||||
{"x-cp20936", 20936}, //Simplified Chinese (GB2312); Chinese Simplified (GB2312-80)
|
|
||||||
{"x-cp20949", 20949}, //Korean Wansung
|
|
||||||
{"cp1025", 21025}, //IBM EBCDIC Cyrillic Serbian-Bulgarian
|
|
||||||
{"deprecated", 21027}, //(deprecated)
|
|
||||||
{"koi8-u", 21866}, //Ukrainian (KOI8-U); Cyrillic (KOI8-U)
|
|
||||||
{"iso-8859-1", 28591}, //ISO 8859-1 Latin 1; Western European (ISO)
|
|
||||||
{"iso-8859-2", 28592}, //ISO 8859-2 Central European; Central European (ISO)
|
|
||||||
{"iso-8859-3", 28593}, //ISO 8859-3 Latin 3
|
|
||||||
{"iso-8859-4", 28594}, //ISO 8859-4 Baltic
|
|
||||||
{"iso-8859-5", 28595}, //ISO 8859-5 Cyrillic
|
|
||||||
{"iso-8859-6", 28596}, //ISO 8859-6 Arabic
|
|
||||||
{"kIso-8859-7", 28597}, //ISO 8859-7 Greek
|
|
||||||
{"iso-8859-8", 28598}, //ISO 8859-8 Hebrew; Hebrew (ISO-Visual)
|
|
||||||
{"iso-8859-9", 28599}, //ISO 8859-9 Turkish
|
|
||||||
{"iso-8859-13", 28603}, //ISO 8859-13 Estonian
|
|
||||||
{"iso-8859-15", 28605}, //ISO 8859-15 Latin 9
|
|
||||||
{"x-europa", 29001}, //Europa 3
|
|
||||||
{"iso-8859-8-i", 38598}, //ISO 8859-8 Hebrew; Hebrew (ISO-Logical)
|
|
||||||
{"iso-2022-jp", 50220}, //ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS)
|
|
||||||
{"csiso2022jp", 50221}, //ISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow 1 byte Kana)
|
|
||||||
{"iso-2022-jp", 50222}, //ISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte Kana - SO/SI)
|
|
||||||
{"iso-2022-kr", 50225}, //ISO 2022 Korean
|
|
||||||
{"x-cp50227", 50227}, //ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022)
|
|
||||||
{"iso2022", 50229}, //Traditional Chinese
|
|
||||||
{"ebcdic1", 50930}, //Japanese (Katakana) Extended
|
|
||||||
{"ebcdic2", 50931}, //US-Canada and Japanese
|
|
||||||
{"ebcdic3", 50933}, //Korean Extended and Korean
|
|
||||||
{"ebcdic4", 50935}, //Simplified Chinese Extended and Simplified Chinese
|
|
||||||
{"ebcdic5", 50936}, //Simplified Chinese
|
|
||||||
{"ebcdic6", 50937}, //US-Canada and Traditional Chinese
|
|
||||||
{"ebcdic7", 50939}, //Japanese (Latin) Extended and Japanese
|
|
||||||
{"euc-jp", 51932}, //EUC Japanese
|
|
||||||
{"euc-cn", 51936}, //EUC Simplified Chinese; Chinese Simplified (EUC)
|
|
||||||
{"euc-kr", 51949}, //EUC Korean
|
|
||||||
{"euc", 51950}, //Traditional Chinese
|
|
||||||
{"hz-gb-2312", 52936}, //HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ)
|
|
||||||
{"gb18030", 54936}, //Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030)
|
|
||||||
{"x-iscii-de", 57002}, //ISCII Devanagari
|
|
||||||
{"x-iscii-be", 57003}, //ISCII Bangla
|
|
||||||
{"x-iscii-ta", 57004}, //ISCII Tamil
|
|
||||||
{"x-iscii-te", 57005}, //ISCII Telugu
|
|
||||||
{"x-iscii-as", 57006}, //ISCII Assamese
|
|
||||||
{"x-iscii-or", 57007}, //ISCII Odia
|
|
||||||
{"x-iscii-ka", 57008}, //ISCII Kannada
|
|
||||||
{"x-iscii-ma", 57009}, //ISCII Malayalam
|
|
||||||
{"x-iscii-gu", 57010}, //ISCII Gujarati
|
|
||||||
{"x-iscii-pa", 57011}, //ISCII Punjabi
|
|
||||||
{"utf-7", 65000}, //Unicode (UTF-7)
|
|
||||||
{"utf-8", 65001}, //Unicode (UTF-8)
|
|
||||||
{nullptr, 0} //End
|
|
||||||
};
|
|
||||||
|
|
||||||
int getCodePageId(Common::String codePageName) {
|
|
||||||
const CodePageDescription *cp = g_cpDescriptions;
|
|
||||||
for (; cp->name; cp++) {
|
|
||||||
if (codePageName.equalsIgnoreCase(cp->name))
|
|
||||||
return cp->id;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // WIN32_CODEPAGE_H
|
|
|
@ -44,7 +44,6 @@
|
||||||
#include "backends/platform/sdl/win32/win32.h"
|
#include "backends/platform/sdl/win32/win32.h"
|
||||||
#include "backends/platform/sdl/win32/win32-window.h"
|
#include "backends/platform/sdl/win32/win32-window.h"
|
||||||
#include "backends/platform/sdl/win32/win32_wrapper.h"
|
#include "backends/platform/sdl/win32/win32_wrapper.h"
|
||||||
#include "backends/platform/sdl/win32/codepage.h"
|
|
||||||
#include "backends/saves/windows/windows-saves.h"
|
#include "backends/saves/windows/windows-saves.h"
|
||||||
#include "backends/fs/windows/windows-fs-factory.h"
|
#include "backends/fs/windows/windows-fs-factory.h"
|
||||||
#include "backends/taskbar/win32/win32-taskbar.h"
|
#include "backends/taskbar/win32/win32-taskbar.h"
|
||||||
|
@ -53,7 +52,6 @@
|
||||||
|
|
||||||
#include "common/memstream.h"
|
#include "common/memstream.h"
|
||||||
#include "common/ustr.h"
|
#include "common/ustr.h"
|
||||||
#include "common/encoding.h"
|
|
||||||
|
|
||||||
#if defined(USE_TTS)
|
#if defined(USE_TTS)
|
||||||
#include "backends/text-to-speech/windows/windows-text-to-speech.h"
|
#include "backends/text-to-speech/windows/windows-text-to-speech.h"
|
||||||
|
@ -398,106 +396,4 @@ AudioCDManager *OSystem_Win32::createAudioCDManager() {
|
||||||
return createWin32AudioCDManager();
|
return createWin32AudioCDManager();
|
||||||
}
|
}
|
||||||
|
|
||||||
char *OSystem_Win32::convertEncoding(const char* to, const char *from, const char *string, size_t length) {
|
|
||||||
char *newString = nullptr;
|
|
||||||
char *result = OSystem_SDL::convertEncoding(to, from, string, length);
|
|
||||||
if (result != nullptr)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
bool swapFromEndian = false;
|
|
||||||
#ifdef SCUMM_BIG_ENDIAN
|
|
||||||
if (Common::String(from).hasSuffixIgnoreCase("le"))
|
|
||||||
swapFromEndian = true;
|
|
||||||
#else
|
|
||||||
if (Common::String(from).hasSuffixIgnoreCase("be"))
|
|
||||||
swapFromEndian = true;
|
|
||||||
#endif
|
|
||||||
if (swapFromEndian) {
|
|
||||||
if (Common::String(from).hasPrefixIgnoreCase("utf-16")) {
|
|
||||||
newString = Common::Encoding::switchEndian(string, length, 16);
|
|
||||||
from = "utf-16";
|
|
||||||
}
|
|
||||||
else if (Common::String(from).hasPrefixIgnoreCase("utf-32")) {
|
|
||||||
newString = Common::Encoding::switchEndian(string, length, 32);
|
|
||||||
from = "utf-32";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return nullptr;
|
|
||||||
if (newString != nullptr)
|
|
||||||
string = newString;
|
|
||||||
else
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
bool swapToEndian = false;
|
|
||||||
#ifdef SCUMM_BIG_ENDIAN
|
|
||||||
if (Common::String(to).hasSuffixIgnoreCase("le"))
|
|
||||||
swapToEndian = true;
|
|
||||||
#else
|
|
||||||
if (Common::String(to).hasSuffixIgnoreCase("be"))
|
|
||||||
swapToEndian = true;
|
|
||||||
#endif
|
|
||||||
// UTF-32 is really important for us, because it is used for the
|
|
||||||
// transliteration in Common::Encoding and Win32 cannot convert it
|
|
||||||
Common::String tempString;
|
|
||||||
if (Common::String(from).hasPrefixIgnoreCase("utf-32")) {
|
|
||||||
Common::U32String UTF32Str((const uint32 *)string, length / 4);
|
|
||||||
tempString = Common::convertUtf32ToUtf8(UTF32Str);
|
|
||||||
string = tempString.c_str();
|
|
||||||
from = "utf-8";
|
|
||||||
}
|
|
||||||
if (Common::String(to).hasPrefixIgnoreCase("utf-32")) {
|
|
||||||
char *UTF8Str = Common::Encoding::convert("utf-8", from, string, length);
|
|
||||||
Common::U32String UTF32Str = Common::convertUtf8ToUtf32(UTF8Str);
|
|
||||||
free(UTF8Str);
|
|
||||||
if (swapToEndian) {
|
|
||||||
result = Common::Encoding::switchEndian((const char *) UTF32Str.c_str(),
|
|
||||||
(UTF32Str.size() + 1) * 4,
|
|
||||||
32);
|
|
||||||
} else {
|
|
||||||
result = (char *) malloc((UTF32Str.size() + 1) * 4);
|
|
||||||
memcpy(result, UTF32Str.c_str(), (UTF32Str.size() + 1) * 4);
|
|
||||||
}
|
|
||||||
if (newString != nullptr)
|
|
||||||
free(newString);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add ending zeros
|
|
||||||
WCHAR *tmpStr;
|
|
||||||
if (Common::String(from).hasPrefixIgnoreCase("utf-16")) {
|
|
||||||
// Allocate space for string and 2 ending zeros
|
|
||||||
tmpStr = (WCHAR *) calloc(sizeof(char), length + 2);
|
|
||||||
if (!tmpStr) {
|
|
||||||
if (newString != nullptr)
|
|
||||||
free(newString);
|
|
||||||
warning("Could not allocate memory for string conversion");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
memcpy(tmpStr, string, length);
|
|
||||||
} else {
|
|
||||||
tmpStr = Win32::ansiToUnicode(string, Win32::getCodePageId(from));
|
|
||||||
if (!tmpStr) {
|
|
||||||
if (newString != nullptr)
|
|
||||||
free(newString);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (newString != nullptr)
|
|
||||||
free(newString);
|
|
||||||
|
|
||||||
if (Common::String(to).hasPrefixIgnoreCase("utf-16")) {
|
|
||||||
if (swapToEndian) {
|
|
||||||
result = Common::Encoding::switchEndian((char *)tmpStr, wcslen(tmpStr) * 2 + 2, 16);
|
|
||||||
free(tmpStr);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
return (char *) tmpStr;
|
|
||||||
} else {
|
|
||||||
result = Win32::unicodeToAnsi(tmpStr, Win32::getCodePageId(to));
|
|
||||||
free(tmpStr);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -54,8 +54,6 @@ protected:
|
||||||
virtual AudioCDManager *createAudioCDManager() override;
|
virtual AudioCDManager *createAudioCDManager() override;
|
||||||
|
|
||||||
HWND getHwnd() { return ((SdlWindow_Win32*)_window)->getHwnd(); }
|
HWND getHwnd() { return ((SdlWindow_Win32*)_window)->getHwnd(); }
|
||||||
|
|
||||||
virtual char *convertEncoding(const char *to, const char *from, const char *string, size_t length) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -50,6 +50,7 @@
|
||||||
"..\..\..\..\NEWS"-"!:\system\apps\scummvm\NEWS"
|
"..\..\..\..\NEWS"-"!:\system\apps\scummvm\NEWS"
|
||||||
|
|
||||||
; Common datafiles needed for some games
|
; Common datafiles needed for some games
|
||||||
|
"..\encoding.dat"-"!:\system\apps\scummvm\encoding.dat"
|
||||||
"..\kyra.dat"-"!:\system\apps\scummvm\kyra.dat"
|
"..\kyra.dat"-"!:\system\apps\scummvm\kyra.dat"
|
||||||
"..\sky.cpt"-"!:\system\apps\scummvm\sky.cpt"
|
"..\sky.cpt"-"!:\system\apps\scummvm\sky.cpt"
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
"..\..\..\..\NEWS"-"!:\system\apps\scummvm\NEWS"
|
"..\..\..\..\NEWS"-"!:\system\apps\scummvm\NEWS"
|
||||||
|
|
||||||
; Common datafiles needed for some games
|
; Common datafiles needed for some games
|
||||||
|
"..\..\..\..\dists\engine-data\encoding.dat"-"!:\system\apps\scummvm\encoding.dat"
|
||||||
"..\..\..\..\dists\engine-data\kyra.dat"-"!:\system\apps\scummvm\kyra.dat"
|
"..\..\..\..\dists\engine-data\kyra.dat"-"!:\system\apps\scummvm\kyra.dat"
|
||||||
"..\..\..\..\dists\engine-data\sky.cpt"-"!:\system\apps\scummvm\sky.cpt"
|
"..\..\..\..\dists\engine-data\sky.cpt"-"!:\system\apps\scummvm\sky.cpt"
|
||||||
"..\..\..\..\dists\engine-data\lure.dat"-"!:\system\apps\scummvm\lure.dat"
|
"..\..\..\..\dists\engine-data\lure.dat"-"!:\system\apps\scummvm\lure.dat"
|
||||||
|
|
|
@ -62,6 +62,7 @@
|
||||||
|
|
||||||
; Common datafiles needed for some games
|
; Common datafiles needed for some games
|
||||||
"..\..\..\..\dists\engine-data\drascula.dat"-"c:\data\scummvm\drascula.dat"
|
"..\..\..\..\dists\engine-data\drascula.dat"-"c:\data\scummvm\drascula.dat"
|
||||||
|
"..\..\..\..\dists\engine-data\encoding.dat"-"c:\system\apps\scummvm\encoding.dat"
|
||||||
"..\..\..\..\dists\engine-data\fonts.dat"-"c:\data\scummvm\fonts.dat"
|
"..\..\..\..\dists\engine-data\fonts.dat"-"c:\data\scummvm\fonts.dat"
|
||||||
"..\..\..\..\dists\engine-data\hugo.dat"-"c:\data\scummvm\hugo.dat"
|
"..\..\..\..\dists\engine-data\hugo.dat"-"c:\data\scummvm\hugo.dat"
|
||||||
"..\..\..\..\dists\engine-data\kyra.dat"-"c:\data\scummvm\kyra.dat"
|
"..\..\..\..\dists\engine-data\kyra.dat"-"c:\data\scummvm\kyra.dat"
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
|
|
||||||
; Common datafiles needed for some games
|
; Common datafiles needed for some games
|
||||||
"..\..\..\..\dists\engine-data\drascula.dat"-"c:\data\scummvm\drascula.dat"
|
"..\..\..\..\dists\engine-data\drascula.dat"-"c:\data\scummvm\drascula.dat"
|
||||||
|
"..\..\..\..\dists\engine-data\encoding.dat"-"c:\data\scummvm\encoding.dat"
|
||||||
"..\..\..\..\dists\engine-data\fonts.dat"-"c:\data\scummvm\fonts.dat"
|
"..\..\..\..\dists\engine-data\fonts.dat"-"c:\data\scummvm\fonts.dat"
|
||||||
"..\..\..\..\dists\engine-data\hugo.dat"-"c:\data\scummvm\hugo.dat"
|
"..\..\..\..\dists\engine-data\hugo.dat"-"c:\data\scummvm\hugo.dat"
|
||||||
"..\..\..\..\dists\engine-data\kyra.dat"-"c:\data\scummvm\kyra.dat"
|
"..\..\..\..\dists\engine-data\kyra.dat"-"c:\data\scummvm\kyra.dat"
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
"..\..\..\..\NEWS"-"!:\system\apps\scummvm\NEWS"
|
"..\..\..\..\NEWS"-"!:\system\apps\scummvm\NEWS"
|
||||||
|
|
||||||
; Common datafiles needed for some games
|
; Common datafiles needed for some games
|
||||||
|
"..\..\..\..\dists\engine-data\encoding.dat"-"!:\system\apps\scummvm\encoding.dat"
|
||||||
"..\..\..\..\dists\engine-data\kyra.dat"-"!:\system\apps\scummvm\kyra.dat"
|
"..\..\..\..\dists\engine-data\kyra.dat"-"!:\system\apps\scummvm\kyra.dat"
|
||||||
"..\..\..\..\dists\engine-data\sky.cpt"-"!:\system\apps\scummvm\sky.cpt"
|
"..\..\..\..\dists\engine-data\sky.cpt"-"!:\system\apps\scummvm\sky.cpt"
|
||||||
"..\..\..\..\dists\engine-data\lure.dat"-"!:\system\apps\scummvm\lure.dat"
|
"..\..\..\..\dists\engine-data\lure.dat"-"!:\system\apps\scummvm\lure.dat"
|
||||||
|
|
|
@ -49,6 +49,7 @@
|
||||||
"..\..\..\..\NEWS"-"!:\system\apps\scummvm\NEWS"
|
"..\..\..\..\NEWS"-"!:\system\apps\scummvm\NEWS"
|
||||||
|
|
||||||
; Common datafiles needed for some games
|
; Common datafiles needed for some games
|
||||||
|
"..\..\..\..\dists\engine-data\encoding.dat"-"!:\system\apps\scummvm\encoding.dat"
|
||||||
"..\..\..\..\dists\engine-data\kyra.dat"-"!:\system\apps\scummvm\kyra.dat"
|
"..\..\..\..\dists\engine-data\kyra.dat"-"!:\system\apps\scummvm\kyra.dat"
|
||||||
"..\..\..\..\dists\engine-data\sky.cpt"-"!:\system\apps\scummvm\sky.cpt"
|
"..\..\..\..\dists\engine-data\sky.cpt"-"!:\system\apps\scummvm\sky.cpt"
|
||||||
"..\..\..\..\dists\engine-data\lure.dat"-"!:\system\apps\scummvm\lure.dat"
|
"..\..\..\..\dists\engine-data\lure.dat"-"!:\system\apps\scummvm\lure.dat"
|
||||||
|
|
|
@ -48,6 +48,7 @@
|
||||||
"..\..\..\..\NEWS"-"!:\system\apps\scummvm\NEWS"
|
"..\..\..\..\NEWS"-"!:\system\apps\scummvm\NEWS"
|
||||||
|
|
||||||
; Common datafiles needed for some games
|
; Common datafiles needed for some games
|
||||||
|
"..\encoding.dat"-"!:\system\apps\scummvm\encoding.dat"
|
||||||
"..\kyra.dat"-"!:\system\apps\scummvm\kyra.dat"
|
"..\kyra.dat"-"!:\system\apps\scummvm\kyra.dat"
|
||||||
"..\sky.cpt"-"!:\system\apps\scummvm\sky.cpt"
|
"..\sky.cpt"-"!:\system\apps\scummvm\sky.cpt"
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@
|
||||||
|
|
||||||
; Common datafiles needed for some games
|
; Common datafiles needed for some games
|
||||||
"..\..\..\..\dists\engine-data\drascula.dat"-"c:\shared\scummvm\drascula.dat"
|
"..\..\..\..\dists\engine-data\drascula.dat"-"c:\shared\scummvm\drascula.dat"
|
||||||
|
"..\..\..\..\dists\engine-data\encoding.dat"-"c:\shared\scummvm\encoding.dat"
|
||||||
"..\..\..\..\dists\engine-data\fonts.dat"-"c:\shared\scummvm\fonts.dat"
|
"..\..\..\..\dists\engine-data\fonts.dat"-"c:\shared\scummvm\fonts.dat"
|
||||||
"..\..\..\..\dists\engine-data\hugo.dat"-"c:\shared\scummvm\hugo.dat"
|
"..\..\..\..\dists\engine-data\hugo.dat"-"c:\shared\scummvm\hugo.dat"
|
||||||
"..\..\..\..\dists\engine-data\kyra.dat"-"c:\shared\scummvm\kyra.dat"
|
"..\..\..\..\dists\engine-data\kyra.dat"-"c:\shared\scummvm\kyra.dat"
|
||||||
|
|
|
@ -68,6 +68,7 @@
|
||||||
|
|
||||||
; Common datafiles needed for some games
|
; Common datafiles needed for some games
|
||||||
"..\..\..\..\dists\engine-data\drascula.dat"-"c:\shared\scummvm\drascula.dat"
|
"..\..\..\..\dists\engine-data\drascula.dat"-"c:\shared\scummvm\drascula.dat"
|
||||||
|
"..\..\..\..\dists\engine-data\encoding.dat"-"c:\shared\scummvm\encoding.dat"
|
||||||
"..\..\..\..\dists\engine-data\fonts.dat"-"c:\shared\scummvm\fonts.dat"
|
"..\..\..\..\dists\engine-data\fonts.dat"-"c:\shared\scummvm\fonts.dat"
|
||||||
"..\..\..\..\dists\engine-data\hugo.dat"-"c:\shared\scummvm\hugo.dat"
|
"..\..\..\..\dists\engine-data\hugo.dat"-"c:\shared\scummvm\hugo.dat"
|
||||||
"..\..\..\..\dists\engine-data\kyra.dat"-"c:\shared\scummvm\kyra.dat"
|
"..\..\..\..\dists\engine-data\kyra.dat"-"c:\shared\scummvm\kyra.dat"
|
||||||
|
|
|
@ -32,7 +32,6 @@
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "common/ustr.h"
|
#include "common/ustr.h"
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "common/encoding.h"
|
|
||||||
|
|
||||||
SPDConnection *_connection;
|
SPDConnection *_connection;
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "common/ustr.h"
|
#include "common/ustr.h"
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "common/encoding.h"
|
|
||||||
|
|
||||||
ISpVoice *_voice;
|
ISpVoice *_voice;
|
||||||
|
|
||||||
|
@ -184,8 +183,8 @@ bool WindowsTextToSpeechManager::say(const Common::U32String &str, Action action
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// We have to set the pitch by prepending xml code at the start of the said string;
|
// We have to set the pitch by prepending xml code at the start of the said string;
|
||||||
Common::U32String pitch = Common::U32String::format(Common::U32String("<pitch absmiddle=\"%d\">%S"), _ttsState->_pitch / 10, str.c_str());
|
Common::U32String pitch = Common::U32String::format("<pitch absmiddle=\"%d\">%S", _ttsState->_pitch / 10, str.c_str());
|
||||||
WCHAR *strW = (WCHAR *) Common::Encoding::convert("UTF-16", pitch);
|
WCHAR *strW = (WCHAR *) pitch.encodeUTF16Native();
|
||||||
if (strW == nullptr) {
|
if (strW == nullptr) {
|
||||||
warning("Cannot convert from UTF-32 encoding for text to speech");
|
warning("Cannot convert from UTF-32 encoding for text to speech");
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -241,30 +241,6 @@ TEMPLATE void BASESTRING::initWithValueTypeStr(const value_type *str, uint32 len
|
||||||
_str[len] = 0;
|
_str[len] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEMPLATE void BASESTRING::initWithCStr(const char *str, uint32 len) {
|
|
||||||
assert(str);
|
|
||||||
|
|
||||||
// Init _storage member explicitly (ie. without calling its constructor)
|
|
||||||
// for GCC 2.95.x compatibility (see also tracker item #1602879).
|
|
||||||
_storage[0] = 0;
|
|
||||||
|
|
||||||
_size = len;
|
|
||||||
|
|
||||||
if (len >= _builtinCapacity) {
|
|
||||||
// Not enough internal storage, so allocate more
|
|
||||||
_extern._capacity = computeCapacity(len + 1);
|
|
||||||
_extern._refCount = nullptr;
|
|
||||||
_str = new value_type[_extern._capacity];
|
|
||||||
assert(_str != nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy the string into the storage area
|
|
||||||
for (size_t idx = 0; idx < len; ++idx, ++str)
|
|
||||||
_str[idx] = (byte)(*str);
|
|
||||||
|
|
||||||
_str[len] = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
TEMPLATE bool BASESTRING::equals(const BaseString &x) const {
|
TEMPLATE bool BASESTRING::equals(const BaseString &x) const {
|
||||||
if (this == &x || _str == x._str) {
|
if (this == &x || _str == x._str) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -243,7 +243,6 @@ protected:
|
||||||
void incRefCount() const;
|
void incRefCount() const;
|
||||||
void decRefCount(int *oldRefCount);
|
void decRefCount(int *oldRefCount);
|
||||||
void initWithValueTypeStr(const value_type *str, uint32 len);
|
void initWithValueTypeStr(const value_type *str, uint32 len);
|
||||||
void initWithCStr(const char *str, uint32 len);
|
|
||||||
|
|
||||||
void assignAppend(const value_type *str);
|
void assignAppend(const value_type *str);
|
||||||
void assignAppend(value_type c);
|
void assignAppend(value_type c);
|
||||||
|
|
|
@ -20,42 +20,28 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef COMMON_ICONV_H
|
#ifndef COMMON_ENC_INTERNAL
|
||||||
#define COMMON_ICONV_H
|
#define COMMON_ENC_INTERNAL 1
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
|
|
||||||
#ifdef USE_ICONV
|
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
class String;
|
extern const uint16 kWindows1250ConversionTable[128];
|
||||||
class U32String;
|
extern const uint16 kWindows1251ConversionTable[128];
|
||||||
|
extern const uint16 kWindows1252ConversionTable[128];
|
||||||
|
extern const uint16 kWindows1253ConversionTable[128];
|
||||||
|
extern const uint16 kWindows1254ConversionTable[128];
|
||||||
|
extern const uint16 kWindows1255ConversionTable[128];
|
||||||
|
extern const uint16 kWindows1256ConversionTable[128];
|
||||||
|
extern const uint16 kWindows1257ConversionTable[128];
|
||||||
|
extern const uint16 kMacCentralEuropeConversionTable[128];
|
||||||
|
extern const uint16 kLatin1ConversionTable[128];
|
||||||
|
extern const uint16 kLatin2ConversionTable[128];
|
||||||
|
extern const uint16 kISO5ConversionTable[128];
|
||||||
|
extern const uint16 kASCIIConversionTable[128];
|
||||||
|
extern const uint16 kDos850ConversionTable[128];
|
||||||
|
extern const uint16 kDos866ConversionTable[128];
|
||||||
|
|
||||||
enum IconvEncoding {
|
}
|
||||||
/** Windows codepage 1250 (Eastern European, Latin alphabet) */
|
|
||||||
kEncodingCP1250,
|
|
||||||
|
|
||||||
/** Windows codepage 1251 (Eastern European, Cyrillic alphabet) */
|
#endif
|
||||||
kEncodingCP1251,
|
|
||||||
|
|
||||||
/** Windows codepage 1252 (Western European, Latin alphabet) */
|
|
||||||
kEncodingCP1252,
|
|
||||||
|
|
||||||
/** Windows codepage 1255 (Hebrew) */
|
|
||||||
kEncodingCP1255,
|
|
||||||
|
|
||||||
/** Windows codepage 932 (Japanese, extended Shift-JIS) */
|
|
||||||
kEncodingCP932,
|
|
||||||
|
|
||||||
/** Macintosh Central European (Eastern European, Latin alphabet) */
|
|
||||||
kEncodingMacCentralEurope
|
|
||||||
};
|
|
||||||
|
|
||||||
U32String convertToU32String(IconvEncoding fromEncoding, const String &string);
|
|
||||||
|
|
||||||
} // End of namespace Common
|
|
||||||
|
|
||||||
#endif // USE_ICONV
|
|
||||||
|
|
||||||
#endif // COMMON_ICONV_H
|
|
|
@ -1,484 +0,0 @@
|
||||||
/* ScummVM - Graphic Adventure Engine
|
|
||||||
*
|
|
||||||
* ScummVM is the legal property of its developers, whose names
|
|
||||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
||||||
* file distributed with this source distribution.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define FORBIDDEN_SYMBOL_ALLOW_ALL
|
|
||||||
#include "common/encoding.h"
|
|
||||||
#include "common/textconsole.h"
|
|
||||||
#include "common/system.h"
|
|
||||||
#include "common/translation.h"
|
|
||||||
#include "common/endian.h"
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#ifdef USE_ICONV
|
|
||||||
|
|
||||||
#include <iconv.h>
|
|
||||||
|
|
||||||
#endif // USE_ICONV
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
String addUtfEndianness(const String &str) {
|
|
||||||
if (str.equalsIgnoreCase("utf-16") || str.equalsIgnoreCase("utf-32")) {
|
|
||||||
#ifdef SCUMM_BIG_ENDIAN
|
|
||||||
return str + "BE";
|
|
||||||
#else
|
|
||||||
return str + "LE";
|
|
||||||
#endif
|
|
||||||
} else
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
Encoding::Encoding(const String &to, const String &from)
|
|
||||||
: _to(to)
|
|
||||||
, _from(from) {
|
|
||||||
}
|
|
||||||
|
|
||||||
char *Encoding::switchEndian(const char *string, int length, int bitCount) {
|
|
||||||
assert(bitCount % 8 == 0);
|
|
||||||
assert(length % (bitCount / 8) == 0);
|
|
||||||
char *newString = (char *)calloc(sizeof(char), length + 4);
|
|
||||||
if (!newString) {
|
|
||||||
warning("Could not allocate memory for string conversion");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
if (bitCount == 16) {
|
|
||||||
int characterCount = length / 2;
|
|
||||||
for(int i = 0; i < characterCount ; i++)
|
|
||||||
((uint16 *)newString)[i] = SWAP_BYTES_16(((const uint16 *)string)[i]);
|
|
||||||
return newString;
|
|
||||||
} else if (bitCount == 32) {
|
|
||||||
int characterCount = length / 4;
|
|
||||||
for(int i = 0; i < characterCount ; i++)
|
|
||||||
((uint32 *)newString)[i] = SWAP_BYTES_32(((const uint32 *)string)[i]);
|
|
||||||
return newString;
|
|
||||||
} else {
|
|
||||||
free(newString);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char *Encoding::convert(const char *string, size_t size) {
|
|
||||||
return convertWithTransliteration(_to, _from, string, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *Encoding::convert(const String &to, const String &from, const char *string, size_t size) {
|
|
||||||
return convertWithTransliteration(to, from, string, size);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *Encoding::convertWithTransliteration(const String &to, const String &from, const char *string, size_t length) {
|
|
||||||
if (from.equalsIgnoreCase(to)) {
|
|
||||||
// don't convert, just copy the string and return it
|
|
||||||
char *result = (char *)calloc(sizeof(char), length + 4);
|
|
||||||
|
|
||||||
if (!result) {
|
|
||||||
warning("Could not allocate memory for string conversion");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
memcpy(result, string, length);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((to.hasPrefixIgnoreCase("utf-16") && from.hasPrefixIgnoreCase("utf-16")) ||
|
|
||||||
(to.hasPrefixIgnoreCase("utf-32") && from.hasPrefixIgnoreCase("utf-32"))) {
|
|
||||||
// Since the two strings are not equal as this is already checked above,
|
|
||||||
// this likely mean that one or both has an endianness suffix, and we
|
|
||||||
// just need to switch the endianess.
|
|
||||||
#ifdef SCUMM_BIG_ENDIAN
|
|
||||||
bool fromBigEndian = !from.hasSuffixIgnoreCase("le");
|
|
||||||
bool toBigEndian = !to.hasSuffixIgnoreCase("le");
|
|
||||||
#else
|
|
||||||
bool fromBigEndian = from.hasSuffixIgnoreCase("be");
|
|
||||||
bool toBigEndian = to.hasSuffixIgnoreCase("be");
|
|
||||||
#endif
|
|
||||||
if (fromBigEndian == toBigEndian) {
|
|
||||||
// don't convert, just copy the string and return it
|
|
||||||
char *result = (char *)calloc(sizeof(char), length + 4);
|
|
||||||
if (!result) {
|
|
||||||
warning("Could not allocate memory for string conversion");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
memcpy(result, string, length);
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
if (to.hasPrefixIgnoreCase("utf-16"))
|
|
||||||
return switchEndian(string, length, 16);
|
|
||||||
else
|
|
||||||
return switchEndian(string, length, 32);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
char *newString = nullptr;
|
|
||||||
String newFrom = from;
|
|
||||||
size_t newLength = length;
|
|
||||||
|
|
||||||
if (from.equalsIgnoreCase("iso-8859-5") &&
|
|
||||||
!to.hasPrefixIgnoreCase("utf")) {
|
|
||||||
// There might be some cyrillic characters, which need to be transliterated.
|
|
||||||
newString = transliterateCyrillic(string);
|
|
||||||
|
|
||||||
if (!newString)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
newFrom = "ASCII";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (from.hasPrefixIgnoreCase("utf") &&
|
|
||||||
!to.hasPrefixIgnoreCase("utf") &&
|
|
||||||
!to.equalsIgnoreCase("iso-8859-5")) {
|
|
||||||
// There might be some cyrillic characters, which need to be transliterated.
|
|
||||||
char *tmpString;
|
|
||||||
if (from.hasPrefixIgnoreCase("utf-32")) {
|
|
||||||
tmpString = nullptr;
|
|
||||||
} else {
|
|
||||||
tmpString = conversion("UTF-32", from, string, length);
|
|
||||||
if (!tmpString)
|
|
||||||
return nullptr;
|
|
||||||
// find out the length in bytes of the tmpString
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; ((const uint32 *)tmpString)[i]; i++)
|
|
||||||
;
|
|
||||||
|
|
||||||
newLength = i * 4;
|
|
||||||
newFrom = "UTF-32";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tmpString != nullptr) {
|
|
||||||
newString = (char *)transliterateUTF32((const uint32 *)tmpString, newLength);
|
|
||||||
free(tmpString);
|
|
||||||
} else {
|
|
||||||
newString = (char *)transliterateUTF32((const uint32 *)string, newLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!newString)
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *result;
|
|
||||||
if (newString != nullptr) {
|
|
||||||
result = conversion(to, newFrom, newString, newLength);
|
|
||||||
free(newString);
|
|
||||||
} else {
|
|
||||||
result = conversion(to, newFrom, string, newLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *Encoding::conversion(const String &to, const String &from, const char *string, size_t length) {
|
|
||||||
char *result = nullptr;
|
|
||||||
#ifdef USE_ICONV
|
|
||||||
result = convertIconv(addUtfEndianness(to).c_str(), addUtfEndianness(from).c_str(), string, length);
|
|
||||||
#endif // USE_ICONV
|
|
||||||
if (result == nullptr)
|
|
||||||
result = g_system->convertEncoding(addUtfEndianness(to).c_str(),
|
|
||||||
addUtfEndianness(from).c_str(), string, length);
|
|
||||||
|
|
||||||
if (result == nullptr) {
|
|
||||||
result = convertConversionTable(addUtfEndianness(to).c_str(), addUtfEndianness(from).c_str(), string, length);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *Encoding::convertIconv(const char *to, const char *from, const char *string, size_t length) {
|
|
||||||
#ifdef USE_ICONV
|
|
||||||
|
|
||||||
String toTranslit = String(to) + "//TRANSLIT";
|
|
||||||
iconv_t iconvHandle = iconv_open(toTranslit.c_str(), from);
|
|
||||||
|
|
||||||
if (iconvHandle == (iconv_t)-1)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
size_t inSize = length;
|
|
||||||
size_t stringSize = inSize > 4 ? inSize : 4;
|
|
||||||
size_t outSize = stringSize;
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef ICONV_USES_CONST
|
|
||||||
const char *src = string;
|
|
||||||
#else
|
|
||||||
char *src = new char[length];
|
|
||||||
char *originalSrc = src;
|
|
||||||
memcpy(src, string, length);
|
|
||||||
#endif // ICONV_USES_CONST
|
|
||||||
|
|
||||||
char *buffer = (char *)calloc(sizeof(char), stringSize);
|
|
||||||
if (!buffer) {
|
|
||||||
#ifndef ICONV_USES_CONST
|
|
||||||
delete[] originalSrc;
|
|
||||||
#endif // ICONV_USES_CONST
|
|
||||||
iconv_close(iconvHandle);
|
|
||||||
warning ("Cannot allocate memory for converting string");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
char *dst = buffer;
|
|
||||||
bool error = false;
|
|
||||||
|
|
||||||
while (true) {
|
|
||||||
if (iconv(iconvHandle, &src, &inSize, &dst, &outSize) == ((size_t)-1)) {
|
|
||||||
// from SDL's implementation of SDL_iconv_string (slightly altered)
|
|
||||||
if (errno == E2BIG) {
|
|
||||||
char *oldString = buffer;
|
|
||||||
stringSize *= 2;
|
|
||||||
buffer = (char *)realloc(buffer, stringSize);
|
|
||||||
if (!buffer) {
|
|
||||||
warning("Cannot allocate memory for converting string");
|
|
||||||
error = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
dst = buffer + (dst - oldString);
|
|
||||||
outSize = stringSize - (dst - buffer);
|
|
||||||
memset(dst, 0, outSize);
|
|
||||||
} else {
|
|
||||||
error = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// we've successfully finished, after the last call with NULLs
|
|
||||||
if (inSize == 0 && src == NULL) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (inSize == 0) {
|
|
||||||
// we're at the end - call one last time with NULLs
|
|
||||||
src = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add a zero character to the end. Hopefuly UTF32 uses the most bytes from
|
|
||||||
// all possible encodings, so add 4 zero bytes.
|
|
||||||
buffer = (char *)realloc(buffer, stringSize + 4);
|
|
||||||
memset(buffer + stringSize, 0, 4);
|
|
||||||
|
|
||||||
#ifndef ICONV_USES_CONST
|
|
||||||
delete[] originalSrc;
|
|
||||||
#endif // ICONV_USES_CONST
|
|
||||||
|
|
||||||
iconv_close(iconvHandle);
|
|
||||||
if (error) {
|
|
||||||
if (buffer)
|
|
||||||
free(buffer);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
return buffer;
|
|
||||||
#else
|
|
||||||
return nullptr;
|
|
||||||
#endif //USE_ICONV
|
|
||||||
}
|
|
||||||
|
|
||||||
static uint32 g_cp850ConversionTable[] = {
|
|
||||||
0x0000, 0x263A, 0x263B, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022,
|
|
||||||
0x25d8, 0x25CB, 0x25D9, 0x2642, 0x2640, 0x266A, 0x266B, 0x263C,
|
|
||||||
0x25BA, 0x25C4, 0x2195, 0x203C, 0x00B6, 0x00A7, 0x25AC, 0x21A8,
|
|
||||||
0x2191, 0x2193, 0x2192, 0x2190, 0x221F, 0x2194, 0x25B2, 0x25BC,
|
|
||||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
|
||||||
0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
|
|
||||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
|
||||||
0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
|
|
||||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
|
||||||
0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
|
|
||||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
|
||||||
0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
|
|
||||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
|
||||||
0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
|
|
||||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
|
||||||
0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x2302,
|
|
||||||
|
|
||||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
|
||||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
|
||||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
|
||||||
0x00FF, 0x00D6, 0x00DC, 0x00F8, 0x00A3, 0x00D8, 0x00D7, 0x0192,
|
|
||||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
|
||||||
0x00BF, 0x00AE, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
|
||||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00C1, 0x00C2, 0x00C0,
|
|
||||||
0x00A9, 0x2563, 0x2551, 0x2557, 0x255D, 0x00A2, 0x00A5, 0x2510,
|
|
||||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x00E3, 0x00C3,
|
|
||||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x00A4,
|
|
||||||
0x00F0, 0x00D0, 0x00CA, 0x00CB, 0x00C8, 0x0131, 0x00CD, 0x00CE,
|
|
||||||
0x00CF, 0x2518, 0x250C, 0x2588, 0x2584, 0x00A6, 0x00CC, 0x2580,
|
|
||||||
0x00D3, 0x00DF, 0x00D4, 0x00D2, 0x00F5, 0x00D5, 0x00B5, 0x00FE,
|
|
||||||
0x00DE, 0x00DA, 0x00DB, 0x00D9, 0x00FD, 0x00DD, 0x00AF, 0x00B4,
|
|
||||||
0x00AD, 0x00B1, 0x2017, 0x00BE, 0x00B6, 0x00A7, 0x00F7, 0x00B8,
|
|
||||||
0x00B0, 0x00A8, 0x00B7, 0x00B9, 0x00B3, 0x00B2, 0x25A0, 0x00A0
|
|
||||||
};
|
|
||||||
|
|
||||||
static uint32 g_cp437ConversionTable[] = {
|
|
||||||
0x0000, 0x263A, 0x263B, 0x2665, 0x2666, 0x2663, 0x2660, 0x2022,
|
|
||||||
0x25d8, 0x25CB, 0x25D9, 0x2642, 0x2640, 0x266A, 0x266B, 0x263C,
|
|
||||||
0x25BA, 0x25C4, 0x2195, 0x203C, 0x00B6, 0x00A7, 0x25AC, 0x21A8,
|
|
||||||
0x2191, 0x2193, 0x2192, 0x2190, 0x221F, 0x2194, 0x25B2, 0x25BC,
|
|
||||||
0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
|
|
||||||
0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F,
|
|
||||||
0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
|
|
||||||
0x0038, 0x0039, 0x003A, 0x003B, 0x003C, 0x003D, 0x003E, 0x003F,
|
|
||||||
0x0040, 0x0041, 0x0042, 0x0043, 0x0044, 0x0045, 0x0046, 0x0047,
|
|
||||||
0x0048, 0x0049, 0x004A, 0x004B, 0x004C, 0x004D, 0x004E, 0x004F,
|
|
||||||
0x0050, 0x0051, 0x0052, 0x0053, 0x0054, 0x0055, 0x0056, 0x0057,
|
|
||||||
0x0058, 0x0059, 0x005A, 0x005B, 0x005C, 0x005D, 0x005E, 0x005F,
|
|
||||||
0x0060, 0x0061, 0x0062, 0x0063, 0x0064, 0x0065, 0x0066, 0x0067,
|
|
||||||
0x0068, 0x0069, 0x006A, 0x006B, 0x006C, 0x006D, 0x006E, 0x006F,
|
|
||||||
0x0070, 0x0071, 0x0072, 0x0073, 0x0074, 0x0075, 0x0076, 0x0077,
|
|
||||||
0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x007D, 0x007E, 0x2302,
|
|
||||||
|
|
||||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
|
||||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
|
||||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
|
||||||
0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
|
|
||||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
|
||||||
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
|
||||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
|
||||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
|
||||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
|
||||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
|
||||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
|
||||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
|
||||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
|
|
||||||
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
|
||||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
|
|
||||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ConversionTable {
|
|
||||||
const char *name;
|
|
||||||
uint32 *table;
|
|
||||||
};
|
|
||||||
|
|
||||||
const ConversionTable g_encodingConversionTables[] = {
|
|
||||||
{"cp850", g_cp850ConversionTable},
|
|
||||||
{"cp437", g_cp437ConversionTable},
|
|
||||||
{nullptr, nullptr}
|
|
||||||
};
|
|
||||||
|
|
||||||
char *Encoding::convertConversionTable(const char *to, const char *from, const char *string, size_t length) {
|
|
||||||
uint32 *table = nullptr;
|
|
||||||
for (const ConversionTable *i = g_encodingConversionTables; i->name != nullptr; i++) {
|
|
||||||
if (String(from).equalsIgnoreCase(i->name)) {
|
|
||||||
table = i->table;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (table != nullptr) {
|
|
||||||
uint32 *utf32Result = (uint32 *)calloc(sizeof(uint32), length + 1);
|
|
||||||
if (!utf32Result) {
|
|
||||||
warning("Could not allocate memory for encoding conversion");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
for (unsigned i = 0; i < length; i++) {
|
|
||||||
utf32Result[i] = table[(unsigned char)string[i]];
|
|
||||||
}
|
|
||||||
char *finalResult = convert(to, "utf-32", (char *)utf32Result, length * 4);
|
|
||||||
free(utf32Result);
|
|
||||||
return finalResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const ConversionTable *i = g_encodingConversionTables; i->name != nullptr; i++) {
|
|
||||||
if (String(to).equalsIgnoreCase(i->name)) {
|
|
||||||
table = i->table;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (table != nullptr) {
|
|
||||||
uint32 *utf32Result = (uint32 *)convert("utf-32", from, string, length);
|
|
||||||
if (String(from).hasPrefixIgnoreCase("utf-16"))
|
|
||||||
length /= 2;
|
|
||||||
if (String(from).hasPrefixIgnoreCase("utf-32"))
|
|
||||||
length /= 4;
|
|
||||||
char *finalResult = (char *)calloc(sizeof(char), length +1);
|
|
||||||
if (!finalResult) {
|
|
||||||
warning("Could not allocate memory for encoding conversion");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
for (unsigned i = 0; i < length; i++) {
|
|
||||||
for (unsigned j = 0; j < 257; j++) {
|
|
||||||
if (j == 256) {
|
|
||||||
// We have some character, that isn't a part of cp850, so
|
|
||||||
// we replace it with '?' to remain consistent with iconv
|
|
||||||
// and SDL
|
|
||||||
finalResult[i] = '?';
|
|
||||||
} else if (utf32Result[i] == table[j]){
|
|
||||||
finalResult[i] = j;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
free(utf32Result);
|
|
||||||
return finalResult;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char g_cyrillicTransliterationTable[] = {
|
|
||||||
' ', 'E', 'D', 'G', 'E', 'Z', 'I', 'I', 'J', 'L', 'N', 'C', 'K', '-', 'U', 'D',
|
|
||||||
'A', 'B', 'V', 'G', 'D', 'E', 'Z', 'Z', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
|
||||||
'R', 'S', 'T', 'U', 'F', 'H', 'C', 'C', 'S', 'S', '\"', 'Y', '\'', 'E', 'U', 'A',
|
|
||||||
'a', 'b', 'v', 'g', 'd', 'e', 'z', 'z', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
|
|
||||||
'r', 's', 't', 'u', 'f', 'h', 'c', 'c', 's', 's', '\"', 'y', '\'', 'e', 'u', 'a',
|
|
||||||
'N', 'e', 'd', 'g', 'e', 'z', 'i', 'i', 'j', 'l', 'n', 'c', 'k', '?', 'u', 'd',
|
|
||||||
};
|
|
||||||
|
|
||||||
char *Encoding::transliterateCyrillic(const char *string) {
|
|
||||||
char *result = (char *)malloc(strlen(string) + 1);
|
|
||||||
if (!result) {
|
|
||||||
warning("Could not allocate memory for encoding conversion");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
for(unsigned i = 0; i <= strlen(string); i++) {
|
|
||||||
if ((unsigned char)string[i] >= 160)
|
|
||||||
result[i] = g_cyrillicTransliterationTable[(unsigned char)string[i] - 160];
|
|
||||||
else
|
|
||||||
result[i] = string[i];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32 *Encoding::transliterateUTF32(const uint32 *string, size_t length) {
|
|
||||||
uint32 *result = (uint32 *)malloc(length + 4);
|
|
||||||
if (!result) {
|
|
||||||
warning("Could not allocate memory for encoding conversion");
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
for(unsigned i = 0; i <= length / 4; i++) {
|
|
||||||
if (string[i] >= 0x410 && string[i] <= 0x450)
|
|
||||||
result[i] = g_cyrillicTransliterationTable[string[i] - 160 - 864];
|
|
||||||
else
|
|
||||||
result[i] = string[i];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t Encoding::stringLength(const char *string, const String &encoding) {
|
|
||||||
if (encoding.hasPrefixIgnoreCase("UTF-16")) {
|
|
||||||
const uint16 *i = (const uint16 *)string;
|
|
||||||
for (;*i != 0; i++) {}
|
|
||||||
return (const char *)i - string;
|
|
||||||
} else if (encoding.hasPrefixIgnoreCase("UTF-32")) {
|
|
||||||
const uint32 *i = (const uint32 *)string;
|
|
||||||
for (;*i != 0; i++) {}
|
|
||||||
return (const char *)i - string;
|
|
||||||
} else {
|
|
||||||
const char *i = string;
|
|
||||||
for (;*i != 0; i++) {}
|
|
||||||
return i - string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,244 +0,0 @@
|
||||||
/* ScummVM - Graphic Adventure Engine
|
|
||||||
*
|
|
||||||
* ScummVM is the legal property of its developers, whose names
|
|
||||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
||||||
* file distributed with this source distribution.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef COMMON_ENCODING_H
|
|
||||||
#define COMMON_ENCODING_H
|
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
|
||||||
#include "common/str.h"
|
|
||||||
#include "common/system.h"
|
|
||||||
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @defgroup common_encoding Text encoding
|
|
||||||
* @ingroup common
|
|
||||||
*
|
|
||||||
* @brief Functions for managing text encoding.
|
|
||||||
*
|
|
||||||
* @{
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A class that allows conversion between different text encoding.
|
|
||||||
* The encodings available depend on the current backend and whether
|
|
||||||
* ScummVM is compiled with or without iconv.
|
|
||||||
*/
|
|
||||||
class Encoding {
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* Construct everything needed for the conversion between two encodings
|
|
||||||
* and saves the values for future use.
|
|
||||||
*
|
|
||||||
* @param to Name of the encoding the strings will be converted to.
|
|
||||||
* @param from Name of the encoding the strings will be converted from.
|
|
||||||
*/
|
|
||||||
Encoding(const String &to, const String &from);
|
|
||||||
~Encoding() {};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a string between encodings.
|
|
||||||
*
|
|
||||||
* The resulting string is ended by a character with value 0
|
|
||||||
* (C-like ending for 1 byte per character encodings, 2 zero bytes for UTF-16,
|
|
||||||
* 4 zero bytes for UTF-32).
|
|
||||||
* The result must be freed after usage using @c free(), not @c delete[].
|
|
||||||
*
|
|
||||||
* @param string String to be converted.
|
|
||||||
* @param length Length of the string to convert in bytes.
|
|
||||||
*
|
|
||||||
* @return Converted string (must be freed) or nullptr if the conversion failed.
|
|
||||||
*/
|
|
||||||
char *convert(const char *string, size_t length);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a string between encodings.
|
|
||||||
*
|
|
||||||
* This is a static version of the method above.
|
|
||||||
* The resulting string is ended by a character with value 0
|
|
||||||
* (C-like ending for 1 byte per character encodings, 2 zero bytes for UTF-16,
|
|
||||||
* 4 zero bytes for UTF-32). The result must be freed after usage.
|
|
||||||
*
|
|
||||||
* @param to Name of the encoding the strings will be converted to.
|
|
||||||
* @param from Name of the encoding the strings will be converted from.
|
|
||||||
* @param string String to be converted.
|
|
||||||
* @param length Length of the string to convert in bytes.
|
|
||||||
*
|
|
||||||
* @return Converted string (must be freed) or nullptr if the conversion failed
|
|
||||||
*/
|
|
||||||
static char *convert(const String &to, const String &from, const char *string, size_t length);
|
|
||||||
|
|
||||||
static char *convert(const String &to, const String &from, const String &s) {
|
|
||||||
return convert(to, from, s.c_str(), s.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
static char *convert(const String &to, const U32String &s) {
|
|
||||||
return convert(to, "UTF-32", (const char *)s.c_str(), s.size() * 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The encoding that is currently being converted from.
|
|
||||||
*/
|
|
||||||
String getFrom() {return _from;};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param from The encoding to convert from.
|
|
||||||
*/
|
|
||||||
void setFrom(const String &from) {_from = from;};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return The encoding that is currently being converted to.
|
|
||||||
*/
|
|
||||||
String getTo() {return _to;};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param to The encoding to convert to.
|
|
||||||
*/
|
|
||||||
void setTo(const String &to) {_to = to;};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Switch the endianness of a string.
|
|
||||||
*
|
|
||||||
* @param string Array containing the characters of a string.
|
|
||||||
* @param length Length of the string in bytes.
|
|
||||||
* @param bitCount Number of bits used for each character.
|
|
||||||
*
|
|
||||||
* @return Array of characters with the opposite endianness.
|
|
||||||
*/
|
|
||||||
static char *switchEndian(const char *string, int length, int bitCount);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Compute the length (in bytes) of a string in a given encoding.
|
|
||||||
*
|
|
||||||
* The string must be zero ended. Similar to @c strlen.
|
|
||||||
*
|
|
||||||
* @note This function must be used instead of @c strlen for some encodings
|
|
||||||
* (such as UTF-16 and UTF-32) because @c strlen does not support
|
|
||||||
* multi-byte encodings, with some exceptions (such as UTF-8).
|
|
||||||
*
|
|
||||||
* @param string The string whose size to compute.
|
|
||||||
* @param encoding Encoding of the string.
|
|
||||||
*
|
|
||||||
* @return Size of the string in bytes.
|
|
||||||
*/
|
|
||||||
static size_t stringLength(const char *string, const String &encoding);
|
|
||||||
|
|
||||||
private:
|
|
||||||
/** The encoding that is currently being converted to. */
|
|
||||||
String _to;
|
|
||||||
|
|
||||||
/** The encoding that is currently being converted from. */
|
|
||||||
String _from;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Take care of transliteration and call conversion.
|
|
||||||
*
|
|
||||||
* The result must be freed after usage.
|
|
||||||
*
|
|
||||||
* @param to Name of the encoding the strings will be converted to.
|
|
||||||
* @param from Name of the encoding the strings will be converted from.
|
|
||||||
* @param string The string to convert.
|
|
||||||
* @param length Length of the string to convert in bytes.
|
|
||||||
*
|
|
||||||
* @return Converted string (must be freed) or nullptr if the conversion failed.
|
|
||||||
*/
|
|
||||||
static char *convertWithTransliteration(const String &to, const String &from, const char *string, size_t length);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call as many conversion functions as possible, or until the conversion
|
|
||||||
* succeeds.
|
|
||||||
*
|
|
||||||
* It first tries to use iconv, then it tries to use platform
|
|
||||||
* specific functions, and after that, it tries to use TransMan mapping.
|
|
||||||
*
|
|
||||||
* The result must be freed after usage.
|
|
||||||
*
|
|
||||||
* @param to Name of the encoding the strings will be converted to.
|
|
||||||
* @param from Name of the encoding the strings will be converted from.
|
|
||||||
* @param string The string to convert.
|
|
||||||
* @param length Length of the string to convert in bytes.
|
|
||||||
*
|
|
||||||
* @return Converted string (must be freed) or nullptr if the conversion failed.
|
|
||||||
*/
|
|
||||||
static char *conversion(const String &to, const String &from, const char *string, size_t length);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempt to convert the string using iconv.
|
|
||||||
*
|
|
||||||
* The result must be freed after usage.
|
|
||||||
*
|
|
||||||
* @param to Name of the encoding the strings will be converted to.
|
|
||||||
* @param from Name of the encoding the strings will be converted from.
|
|
||||||
* @param string The string to convert.
|
|
||||||
* @param length Length of the string to convert in bytes.
|
|
||||||
*
|
|
||||||
* @return Converted string (must be freed) or nullptr if the conversion failed.
|
|
||||||
*/
|
|
||||||
static char *convertIconv(const char *to, const char *from, const char *string, size_t length);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Use a conversion table to convert the string to unicode, and from that,
|
|
||||||
* to the final encoding. Important encodings, that are not supported by
|
|
||||||
* all backends should go here.
|
|
||||||
*
|
|
||||||
* The result must be freed after usage.
|
|
||||||
*
|
|
||||||
* @param to Name of the encoding the strings will be converted to.
|
|
||||||
* @param from Name of the encoding the strings will be converted from.
|
|
||||||
* @param string The string to be converted.
|
|
||||||
* @param length Length of the string to convert in bytes.
|
|
||||||
*
|
|
||||||
* @return Converted string (must be freed) or nullptr if the conversion failed.
|
|
||||||
*/
|
|
||||||
static char *convertConversionTable(const char *to, const char *from, const char *string, size_t length);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transliterate a Cyrillic string in ISO-8859-5 encoding and return
|
|
||||||
* its ASCII (Latin) form.
|
|
||||||
*
|
|
||||||
* The result must be freed after usage.
|
|
||||||
*
|
|
||||||
* @param string The string to convert.
|
|
||||||
*
|
|
||||||
* @return Transliterated string in ASCII (must be freed) or nullptr on fail.
|
|
||||||
*/
|
|
||||||
static char *transliterateCyrillic(const char *string);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Transliterate a Cyrillic string into a UTF-32 string.
|
|
||||||
*
|
|
||||||
* The result must be freed after usage.
|
|
||||||
*
|
|
||||||
* @param string The string to convert.
|
|
||||||
* @param length Length of the string in bytes.
|
|
||||||
*
|
|
||||||
* @return Transliterated string in UTF-32 (must be freed) or nullptr on fail.
|
|
||||||
*/
|
|
||||||
static uint32 *transliterateUTF32(const uint32 *string, size_t length);
|
|
||||||
};
|
|
||||||
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // COMMON_ENCODING_H
|
|
266
common/encodings/singlebyte.cpp
Normal file
266
common/encodings/singlebyte.cpp
Normal file
|
@ -0,0 +1,266 @@
|
||||||
|
#include "common/scummsys.h"
|
||||||
|
#include "common/enc-internal.h"
|
||||||
|
|
||||||
|
namespace Common {
|
||||||
|
|
||||||
|
const uint16 kWindows1250ConversionTable[128] = {
|
||||||
|
0x20AC, 0x0081, 0x201A, 0x0083, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||||
|
0x0088, 0x2030, 0x0160, 0x2039, 0x015A, 0x0164, 0x017D, 0x0179,
|
||||||
|
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||||
|
0x0098, 0x2122, 0x0161, 0x203A, 0x015B, 0x0165, 0x017E, 0x017A,
|
||||||
|
0x00A0, 0x02C7, 0x02D8, 0x0141, 0x00A4, 0x0104, 0x00A6, 0x00A7,
|
||||||
|
0x00A8, 0x00A9, 0x015E, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x017B,
|
||||||
|
0x00B0, 0x00B1, 0x02DB, 0x0142, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||||
|
0x00B8, 0x0105, 0x015F, 0x00BB, 0x013D, 0x02DD, 0x013E, 0x017C,
|
||||||
|
0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
|
||||||
|
0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
|
||||||
|
0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
|
||||||
|
0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
|
||||||
|
0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
|
||||||
|
0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
|
||||||
|
0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
|
||||||
|
0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9};
|
||||||
|
|
||||||
|
const uint16 kWindows1251ConversionTable[128] = {
|
||||||
|
0x0402, 0x0403, 0x201A, 0x0453, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||||
|
0x20AC, 0x2030, 0x0409, 0x2039, 0x040A, 0x040C, 0x040B, 0x040F,
|
||||||
|
0x0452, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||||
|
0x0098, 0x2122, 0x0459, 0x203A, 0x045A, 0x045C, 0x045B, 0x045F,
|
||||||
|
0x00A0, 0x040E, 0x045E, 0x0408, 0x00A4, 0x0490, 0x00A6, 0x00A7,
|
||||||
|
0x0401, 0x00A9, 0x0404, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x0407,
|
||||||
|
0x00B0, 0x00B1, 0x0406, 0x0456, 0x0491, 0x00B5, 0x00B6, 0x00B7,
|
||||||
|
0x0451, 0x2116, 0x0454, 0x00BB, 0x0458, 0x0405, 0x0455, 0x0457,
|
||||||
|
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
|
||||||
|
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
||||||
|
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
|
||||||
|
0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
|
||||||
|
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
|
||||||
|
0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
|
||||||
|
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
|
||||||
|
0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F};
|
||||||
|
|
||||||
|
const uint16 kWindows1252ConversionTable[128] = {
|
||||||
|
0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||||
|
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x017D, 0x008F,
|
||||||
|
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||||
|
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x017E, 0x0178,
|
||||||
|
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||||
|
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||||
|
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||||
|
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||||
|
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
|
||||||
|
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
||||||
|
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
|
||||||
|
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
|
||||||
|
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
|
||||||
|
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
||||||
|
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
|
||||||
|
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF};
|
||||||
|
|
||||||
|
const uint16 kWindows1253ConversionTable[128] = {
|
||||||
|
0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||||
|
0x0088, 0x2030, 0x008A, 0x2039, 0x008C, 0x008D, 0x008E, 0x008F,
|
||||||
|
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||||
|
0x0098, 0x2122, 0x009A, 0x203A, 0x009C, 0x009D, 0x009E, 0x009F,
|
||||||
|
0x00A0, 0x0385, 0x0386, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||||
|
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x2015,
|
||||||
|
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x0384, 0x00B5, 0x00B6, 0x00B7,
|
||||||
|
0x0388, 0x0389, 0x038A, 0x00BB, 0x038C, 0x00BD, 0x038E, 0x038F,
|
||||||
|
0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397,
|
||||||
|
0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x039D, 0x039E, 0x039F,
|
||||||
|
0x03A0, 0x03A1, 0x00D2, 0x03A3, 0x03A4, 0x03A5, 0x03A6, 0x03A7,
|
||||||
|
0x03A8, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x03AD, 0x03AE, 0x03AF,
|
||||||
|
0x03B0, 0x03B1, 0x03B2, 0x03B3, 0x03B4, 0x03B5, 0x03B6, 0x03B7,
|
||||||
|
0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03BF,
|
||||||
|
0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03C7,
|
||||||
|
0x03C8, 0x03C9, 0x03CA, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0x00FF};
|
||||||
|
|
||||||
|
const uint16 kWindows1254ConversionTable[128] = {
|
||||||
|
0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||||
|
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x008D, 0x008E, 0x008F,
|
||||||
|
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||||
|
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x009D, 0x009E, 0x0178,
|
||||||
|
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||||
|
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||||
|
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||||
|
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||||
|
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
|
||||||
|
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
||||||
|
0x011E, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
|
||||||
|
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x0130, 0x015E, 0x00DF,
|
||||||
|
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
|
||||||
|
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
||||||
|
0x011F, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
|
||||||
|
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x0131, 0x015F, 0x00FF};
|
||||||
|
|
||||||
|
const uint16 kWindows1255ConversionTable[128] = {
|
||||||
|
0x20AC, 0x0081, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||||
|
0x02C6, 0x2030, 0x008A, 0x2039, 0x008C, 0x008D, 0x008E, 0x008F,
|
||||||
|
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||||
|
0x02DC, 0x2122, 0x009A, 0x203A, 0x009C, 0x009D, 0x009E, 0x009F,
|
||||||
|
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x20AA, 0x00A5, 0x00A6, 0x00A7,
|
||||||
|
0x00A8, 0x00A9, 0x00D7, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||||
|
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||||
|
0x00B8, 0x00B9, 0x00F7, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||||
|
0x05B0, 0x05B1, 0x05B2, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7,
|
||||||
|
0x05B8, 0x05B9, 0x05BA, 0x05BB, 0x05BC, 0x05BD, 0x05BE, 0x05BF,
|
||||||
|
0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05F0, 0x05F1, 0x05F2, 0x05F3,
|
||||||
|
0x05F4, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
|
||||||
|
0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05D7,
|
||||||
|
0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05DF,
|
||||||
|
0x05E0, 0x05E1, 0x05E2, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x05E7,
|
||||||
|
0x05E8, 0x05E9, 0x05EA, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x00FF};
|
||||||
|
|
||||||
|
const uint16 kWindows1256ConversionTable[128] = {
|
||||||
|
0x20AC, 0x067E, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||||
|
0x02C6, 0x2030, 0x0679, 0x2039, 0x0152, 0x0686, 0x0698, 0x0688,
|
||||||
|
0x06AF, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||||
|
0x06A9, 0x2122, 0x0691, 0x203A, 0x0153, 0x200C, 0x200D, 0x06BA,
|
||||||
|
0x00A0, 0x060C, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||||
|
0x00A8, 0x00A9, 0x06BE, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||||
|
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||||
|
0x00B8, 0x00B9, 0x061B, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x061F,
|
||||||
|
0x06C1, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627,
|
||||||
|
0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F,
|
||||||
|
0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x00D7,
|
||||||
|
0x0637, 0x0638, 0x0639, 0x063A, 0x0640, 0x0641, 0x0642, 0x0643,
|
||||||
|
0x00E0, 0x0644, 0x00E2, 0x0645, 0x0646, 0x0647, 0x0648, 0x00E7,
|
||||||
|
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0649, 0x064A, 0x00EE, 0x00EF,
|
||||||
|
0x064B, 0x064C, 0x064D, 0x064E, 0x00F4, 0x064F, 0x0650, 0x00F7,
|
||||||
|
0x0651, 0x00F9, 0x0652, 0x00FB, 0x00FC, 0x200E, 0x200F, 0x06D2};
|
||||||
|
|
||||||
|
const uint16 kWindows1257ConversionTable[128] = {
|
||||||
|
0x20AC, 0x0081, 0x201A, 0x0083, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||||
|
0x0088, 0x2030, 0x008A, 0x2039, 0x008C, 0x00A8, 0x02C7, 0x00B8,
|
||||||
|
0x0090, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||||
|
0x0098, 0x2122, 0x009A, 0x203A, 0x009C, 0x00AF, 0x02DB, 0x009F,
|
||||||
|
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||||
|
0x00D8, 0x00A9, 0x0156, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00C6,
|
||||||
|
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||||
|
0x00F8, 0x00B9, 0x0157, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00E6,
|
||||||
|
0x0104, 0x012E, 0x0100, 0x0106, 0x00C4, 0x00C5, 0x0118, 0x0112,
|
||||||
|
0x010C, 0x00C9, 0x0179, 0x0116, 0x0122, 0x0136, 0x012A, 0x013B,
|
||||||
|
0x0160, 0x0143, 0x0145, 0x00D3, 0x014C, 0x00D5, 0x00D6, 0x00D7,
|
||||||
|
0x0172, 0x0141, 0x015A, 0x016A, 0x00DC, 0x017B, 0x017D, 0x00DF,
|
||||||
|
0x0105, 0x012F, 0x0101, 0x0107, 0x00E4, 0x00E5, 0x0119, 0x0113,
|
||||||
|
0x010D, 0x00E9, 0x017A, 0x0117, 0x0123, 0x0137, 0x012B, 0x013C,
|
||||||
|
0x0161, 0x0144, 0x0146, 0x00F3, 0x014D, 0x00F5, 0x00F6, 0x00F7,
|
||||||
|
0x0173, 0x0142, 0x015B, 0x016B, 0x00FC, 0x017C, 0x017E, 0x02D9};
|
||||||
|
|
||||||
|
const uint16 kMacCentralEuropeConversionTable[128] = {
|
||||||
|
0x00C4, 0x0100, 0x0101, 0x00C9, 0x0104, 0x00D6, 0x00DC, 0x00E1,
|
||||||
|
0x0105, 0x010C, 0x00E4, 0x010D, 0x0106, 0x0107, 0x00E9, 0x0179,
|
||||||
|
0x017A, 0x010E, 0x00ED, 0x010F, 0x0112, 0x0113, 0x0116, 0x00F3,
|
||||||
|
0x0117, 0x00F4, 0x00F6, 0x00F5, 0x00FA, 0x011A, 0x011B, 0x00FC,
|
||||||
|
0x2020, 0x00B0, 0x0118, 0x00A3, 0x00A7, 0x2022, 0x00B6, 0x00DF,
|
||||||
|
0x00AE, 0x00A9, 0x2122, 0x0119, 0x00A8, 0x2260, 0x0123, 0x012E,
|
||||||
|
0x012F, 0x012A, 0x2264, 0x2265, 0x012B, 0x0136, 0x2202, 0x2211,
|
||||||
|
0x0142, 0x013B, 0x013C, 0x013D, 0x013E, 0x0139, 0x013A, 0x0145,
|
||||||
|
0x0146, 0x0143, 0x00AC, 0x221A, 0x0144, 0x0147, 0x2206, 0x00AB,
|
||||||
|
0x00BB, 0x2026, 0x00A0, 0x0148, 0x0150, 0x00D5, 0x0151, 0x014C,
|
||||||
|
0x2013, 0x2014, 0x201C, 0x201D, 0x2018, 0x2019, 0x00F7, 0x25CA,
|
||||||
|
0x014D, 0x0154, 0x0155, 0x0158, 0x2039, 0x203A, 0x0159, 0x0156,
|
||||||
|
0x0157, 0x0160, 0x201A, 0x201E, 0x0161, 0x015A, 0x015B, 0x00C1,
|
||||||
|
0x0164, 0x0165, 0x00CD, 0x017D, 0x017E, 0x016A, 0x00D3, 0x00D4,
|
||||||
|
0x016B, 0x016E, 0x00DA, 0x016F, 0x0170, 0x0171, 0x0172, 0x0173,
|
||||||
|
0x00DD, 0x00FD, 0x0137, 0x017B, 0x0141, 0x017C, 0x0122, 0x02C7
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16 kLatin1ConversionTable[128] = {
|
||||||
|
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
|
||||||
|
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
||||||
|
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
|
||||||
|
0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
||||||
|
0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7,
|
||||||
|
0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x00AC, 0x00AD, 0x00AE, 0x00AF,
|
||||||
|
0x00B0, 0x00B1, 0x00B2, 0x00B3, 0x00B4, 0x00B5, 0x00B6, 0x00B7,
|
||||||
|
0x00B8, 0x00B9, 0x00BA, 0x00BB, 0x00BC, 0x00BD, 0x00BE, 0x00BF,
|
||||||
|
0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00C4, 0x00C5, 0x00C6, 0x00C7,
|
||||||
|
0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF,
|
||||||
|
0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7,
|
||||||
|
0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x00DC, 0x00DD, 0x00DE, 0x00DF,
|
||||||
|
0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x00E4, 0x00E5, 0x00E6, 0x00E7,
|
||||||
|
0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x00EC, 0x00ED, 0x00EE, 0x00EF,
|
||||||
|
0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F4, 0x00F5, 0x00F6, 0x00F7,
|
||||||
|
0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x00FC, 0x00FD, 0x00FE, 0x00FF,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16 kLatin2ConversionTable[128] = {
|
||||||
|
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
|
||||||
|
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
||||||
|
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
|
||||||
|
0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
||||||
|
0x00A0, 0x0104, 0x02D8, 0x0141, 0x00A4, 0x013D, 0x015A, 0x00A7,
|
||||||
|
0x00A8, 0x0160, 0x015E, 0x0164, 0x0179, 0x00AD, 0x017D, 0x017B,
|
||||||
|
0x00B0, 0x0105, 0x02DB, 0x0142, 0x00B4, 0x013E, 0x015B, 0x02C7,
|
||||||
|
0x00B8, 0x0161, 0x015F, 0x0165, 0x017A, 0x02DD, 0x017E, 0x017C,
|
||||||
|
0x0154, 0x00C1, 0x00C2, 0x0102, 0x00C4, 0x0139, 0x0106, 0x00C7,
|
||||||
|
0x010C, 0x00C9, 0x0118, 0x00CB, 0x011A, 0x00CD, 0x00CE, 0x010E,
|
||||||
|
0x0110, 0x0143, 0x0147, 0x00D3, 0x00D4, 0x0150, 0x00D6, 0x00D7,
|
||||||
|
0x0158, 0x016E, 0x00DA, 0x0170, 0x00DC, 0x00DD, 0x0162, 0x00DF,
|
||||||
|
0x0155, 0x00E1, 0x00E2, 0x0103, 0x00E4, 0x013A, 0x0107, 0x00E7,
|
||||||
|
0x010D, 0x00E9, 0x0119, 0x00EB, 0x011B, 0x00ED, 0x00EE, 0x010F,
|
||||||
|
0x0111, 0x0144, 0x0148, 0x00F3, 0x00F4, 0x0151, 0x00F6, 0x00F7,
|
||||||
|
0x0159, 0x016F, 0x00FA, 0x0171, 0x00FC, 0x00FD, 0x0163, 0x02D9,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16 kISO5ConversionTable[128] = {
|
||||||
|
0x0080, 0x0081, 0x0082, 0x0083, 0x0084, 0x0085, 0x0086, 0x0087,
|
||||||
|
0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x008D, 0x008E, 0x008F,
|
||||||
|
0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097,
|
||||||
|
0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F,
|
||||||
|
0x00A0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407,
|
||||||
|
0x0408, 0x0409, 0x040A, 0x040B, 0x040C, 0x00AD, 0x040E, 0x040F,
|
||||||
|
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
|
||||||
|
0x0418, 0x0419, 0x041A, 0x041B, 0x041C, 0x041D, 0x041E, 0x041F,
|
||||||
|
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
|
||||||
|
0x0428, 0x0429, 0x042A, 0x042B, 0x042C, 0x042D, 0x042E, 0x042F,
|
||||||
|
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
|
||||||
|
0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F,
|
||||||
|
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
|
||||||
|
0x0448, 0x0449, 0x044A, 0x044B, 0x044C, 0x044D, 0x044E, 0x044F,
|
||||||
|
0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457,
|
||||||
|
0x0458, 0x0459, 0x045A, 0x045B, 0x045C, 0x00A7, 0x045E, 0x045F,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16 kASCIIConversionTable[128] = {
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16 kDos850ConversionTable[128] = {
|
||||||
|
0x00c7, 0x00fc, 0x00e9, 0x00e2, 0x00e4, 0x00e0, 0x00e5, 0x00e7,
|
||||||
|
0x00ea, 0x00eb, 0x00e8, 0x00ef, 0x00ee, 0x00ec, 0x00c4, 0x00c5,
|
||||||
|
0x00c9, 0x00e6, 0x00c6, 0x00f4, 0x00f6, 0x00f2, 0x00fb, 0x00f9,
|
||||||
|
0x00ff, 0x00d6, 0x00dc, 0x00f8, 0x00a3, 0x00d8, 0x00d7, 0x0192,
|
||||||
|
0x00e1, 0x00ed, 0x00f3, 0x00fa, 0x00f1, 0x00d1, 0x00aa, 0x00ba,
|
||||||
|
0x00bf, 0x00ae, 0x00ac, 0x00bd, 0x00bc, 0x00a1, 0x00ab, 0x00bb,
|
||||||
|
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x00c1, 0x00c2, 0x00c0,
|
||||||
|
0x00a9, 0x2563, 0x2551, 0x2557, 0x255d, 0x00a2, 0x00a5, 0x2510,
|
||||||
|
0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x00e3, 0x00c3,
|
||||||
|
0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x00a4,
|
||||||
|
0x00f0, 0x00d0, 0x00ca, 0x00cb, 0x00c8, 0x0131, 0x00cd, 0x00ce,
|
||||||
|
0x00cf, 0x2518, 0x250c, 0x2588, 0x2584, 0x00a6, 0x00cc, 0x2580,
|
||||||
|
0x00d3, 0x00df, 0x00d4, 0x00d2, 0x00f5, 0x00d5, 0x00b5, 0x00fe,
|
||||||
|
0x00de, 0x00da, 0x00db, 0x00d9, 0x00fd, 0x00dd, 0x00af, 0x00b4,
|
||||||
|
0x00ad, 0x00b1, 0x2017, 0x00be, 0x00b6, 0x00a7, 0x00f7, 0x00b8,
|
||||||
|
0x00b0, 0x00a8, 0x00b7, 0x00b9, 0x00b3, 0x00b2, 0x25a0, 0x00a0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint16 kDos866ConversionTable[128] = {
|
||||||
|
0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417,
|
||||||
|
0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f,
|
||||||
|
0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427,
|
||||||
|
0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f,
|
||||||
|
0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437,
|
||||||
|
0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f,
|
||||||
|
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||||
|
0x2555, 0x2563, 0x2551, 0x2557, 0x255d, 0x255c, 0x255b, 0x2510,
|
||||||
|
0x2514, 0x2534, 0x252c, 0x251c, 0x2500, 0x253c, 0x255e, 0x255f,
|
||||||
|
0x255a, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256c, 0x2567,
|
||||||
|
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256b,
|
||||||
|
0x256a, 0x2518, 0x250c, 0x2588, 0x2584, 0x258c, 0x2590, 0x2580,
|
||||||
|
0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447,
|
||||||
|
0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f,
|
||||||
|
0x0401, 0x0451, 0x0404, 0x0454, 0x0407, 0x0457, 0x040e, 0x045e,
|
||||||
|
0x00b0, 0x2219, 0x00b7, 0x221a, 0x2116, 0x00a4, 0x25a0, 0x00a0,
|
||||||
|
};
|
||||||
|
}
|
106
common/iconv.cpp
106
common/iconv.cpp
|
@ -1,106 +0,0 @@
|
||||||
/* ScummVM - Graphic Adventure Engine
|
|
||||||
*
|
|
||||||
* ScummVM is the legal property of its developers, whose names
|
|
||||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
||||||
* file distributed with this source distribution.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <iconv.h>
|
|
||||||
|
|
||||||
#include "common/iconv.h"
|
|
||||||
#include "common/str.h"
|
|
||||||
#include "common/textconsole.h"
|
|
||||||
#include "common/ustr.h"
|
|
||||||
|
|
||||||
namespace Common {
|
|
||||||
|
|
||||||
static const char **getIconvCodesForEncoding(IconvEncoding encoding) {
|
|
||||||
static const char *encodingCP932Codes[] = { "cp932", nullptr };
|
|
||||||
static const char *encodingCP1250Codes[] = { "cp1250", nullptr };
|
|
||||||
static const char *encodingCP1251Codes[] = { "cp1251", nullptr };
|
|
||||||
static const char *encodingCP1252Codes[] = { "cp1252", nullptr };
|
|
||||||
static const char *encodingCP1255Codes[] = { "cp1255", nullptr };
|
|
||||||
|
|
||||||
// libiconv and glibc-iconv don't use the same name for that encoding, we have to try both
|
|
||||||
static const char *encodingMacCentralEuropeCodes[] = { "maccentraleurope", "mac-centraleurope", nullptr };
|
|
||||||
|
|
||||||
switch (encoding) {
|
|
||||||
case kEncodingCP932: return encodingCP932Codes;
|
|
||||||
case kEncodingCP1250: return encodingCP1250Codes;
|
|
||||||
case kEncodingCP1251: return encodingCP1251Codes;
|
|
||||||
case kEncodingCP1252: return encodingCP1252Codes;
|
|
||||||
case kEncodingCP1255: return encodingCP1255Codes;
|
|
||||||
case kEncodingMacCentralEurope: return encodingMacCentralEuropeCodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
error("Failed look up iconv codes for encoding '%d'", encoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
U32String convertToU32String(IconvEncoding fromEncoding, const String &string) {
|
|
||||||
const char **fromCodes = getIconvCodesForEncoding(fromEncoding);
|
|
||||||
|
|
||||||
// Apparently UTF-32 isn't native endian. Also, UCS−4−INTERNAL fails
|
|
||||||
// for me.
|
|
||||||
static const char *toCode =
|
|
||||||
#ifdef SCUMM_BIG_ENDIAN
|
|
||||||
"UTF-32BE";
|
|
||||||
#else
|
|
||||||
"UTF-32LE";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
iconv_t handle;
|
|
||||||
do {
|
|
||||||
handle = iconv_open(toCode, *fromCodes);
|
|
||||||
|
|
||||||
if (handle == (iconv_t)-1) {
|
|
||||||
fromCodes++;
|
|
||||||
}
|
|
||||||
} while (handle == ((iconv_t)-1) && *fromCodes);
|
|
||||||
|
|
||||||
if (handle == ((iconv_t)-1))
|
|
||||||
error("Failed to initialize UTF-32 conversion from %d", fromEncoding);
|
|
||||||
|
|
||||||
size_t inSize = string.size();
|
|
||||||
size_t outSize = inSize * 4; // Approximation
|
|
||||||
size_t originalOutSize = outSize;
|
|
||||||
|
|
||||||
char *buffer = new char[outSize];
|
|
||||||
char *dst = buffer;
|
|
||||||
|
|
||||||
#ifdef ICONV_USES_CONST
|
|
||||||
const char *src = string.c_str();
|
|
||||||
#else
|
|
||||||
char *src = const_cast<char *>(string.c_str());
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (iconv(handle, &src, &inSize, &dst, &outSize) == ((size_t)-1))
|
|
||||||
error("Failed to convert %s to UTF-32 string", *fromCodes);
|
|
||||||
|
|
||||||
// The conversion descriptor may still contain some state. Write it to the output buffer.
|
|
||||||
if (iconv(handle, nullptr, nullptr, &dst, &outSize) == ((size_t)-1))
|
|
||||||
error("Failed to convert the remaining state of %s to UTF-32 string", *fromCodes);
|
|
||||||
|
|
||||||
U32String output((const U32String::value_type *)buffer, (originalOutSize - outSize) / 4);
|
|
||||||
|
|
||||||
delete[] buffer;
|
|
||||||
iconv_close(handle);
|
|
||||||
|
|
||||||
return output;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End of namespace Common
|
|
|
@ -33,9 +33,10 @@ MODULE_OBJS := \
|
||||||
rendermode.o \
|
rendermode.o \
|
||||||
sinewindows.o \
|
sinewindows.o \
|
||||||
str.o \
|
str.o \
|
||||||
str-enc.o \
|
|
||||||
stream.o \
|
stream.o \
|
||||||
streamdebug.o \
|
streamdebug.o \
|
||||||
|
str-enc.o \
|
||||||
|
encodings/singlebyte.o \
|
||||||
stuffit.o \
|
stuffit.o \
|
||||||
system.o \
|
system.o \
|
||||||
textconsole.o \
|
textconsole.o \
|
||||||
|
@ -57,7 +58,6 @@ MODULE_OBJS += \
|
||||||
dct.o \
|
dct.o \
|
||||||
fft.o \
|
fft.o \
|
||||||
rdft.o \
|
rdft.o \
|
||||||
encoding.o \
|
|
||||||
sinetables.o
|
sinetables.o
|
||||||
|
|
||||||
ifdef ENABLE_EVENTRECORDER
|
ifdef ENABLE_EVENTRECORDER
|
||||||
|
@ -111,10 +111,5 @@ MODULE_OBJS += \
|
||||||
text-to-speech.o
|
text-to-speech.o
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef USE_ICONV
|
|
||||||
MODULE_OBJS += \
|
|
||||||
iconv.o
|
|
||||||
endif
|
|
||||||
|
|
||||||
# Include common rules
|
# Include common rules
|
||||||
include $(srcdir)/rules.mk
|
include $(srcdir)/rules.mk
|
||||||
|
|
1063
common/str-enc.cpp
1063
common/str-enc.cpp
File diff suppressed because it is too large
Load diff
|
@ -41,7 +41,18 @@ enum CodePage {
|
||||||
kWindows1257,
|
kWindows1257,
|
||||||
kWindows932,
|
kWindows932,
|
||||||
kWindows949,
|
kWindows949,
|
||||||
kWindows950
|
kWindows950,
|
||||||
|
kISO8859_1,
|
||||||
|
kISO8859_2,
|
||||||
|
kISO8859_5,
|
||||||
|
kMacCentralEurope,
|
||||||
|
kDos850,
|
||||||
|
kDos866,
|
||||||
|
kASCII,
|
||||||
|
|
||||||
|
kLatin1 = kISO8859_1,
|
||||||
|
kBig5 = kWindows950,
|
||||||
|
kLastEncoding = kASCII
|
||||||
};
|
};
|
||||||
|
|
||||||
U32String convertUtf8ToUtf32(const String &str);
|
U32String convertUtf8ToUtf32(const String &str);
|
||||||
|
@ -49,6 +60,7 @@ String convertUtf32ToUtf8(const U32String &str);
|
||||||
|
|
||||||
U32String convertToU32String(const char *str, CodePage page = kUtf8);
|
U32String convertToU32String(const char *str, CodePage page = kUtf8);
|
||||||
String convertFromU32String(const U32String &str, CodePage page = kUtf8);
|
String convertFromU32String(const U32String &str, CodePage page = kUtf8);
|
||||||
|
uint16 convertUHCToUCS(uint8 high, uint8 low);
|
||||||
} // End of namespace Common
|
} // End of namespace Common
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -39,10 +39,10 @@ String::String(char c)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef SCUMMVM_UTIL
|
#ifndef SCUMMVM_UTIL
|
||||||
String::String(const U32String &str)
|
String::String(const U32String &str, Common::CodePage page)
|
||||||
: BaseString<char>() {
|
: BaseString<char>() {
|
||||||
_storage[0] = 0;
|
_storage[0] = 0;
|
||||||
*this = String(str.encode());
|
*this = String(str.encode(page));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
13
common/str.h
13
common/str.h
|
@ -85,7 +85,7 @@ public:
|
||||||
explicit String(char c);
|
explicit String(char c);
|
||||||
|
|
||||||
/** Construct a new string from the given u32 string. */
|
/** Construct a new string from the given u32 string. */
|
||||||
String(const U32String &str);
|
String(const U32String &str, CodePage page = kUtf8);
|
||||||
|
|
||||||
String &operator=(const char *str);
|
String &operator=(const char *str);
|
||||||
String &operator=(const String &str);
|
String &operator=(const String &str);
|
||||||
|
@ -246,8 +246,15 @@ public:
|
||||||
U32String decode(CodePage page = kUtf8) const;
|
U32String decode(CodePage page = kUtf8) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void decodeUTF8(U32String &dst) const;
|
void encodeUTF8(const U32String &src);
|
||||||
void decodeOneByte(U32String &dst, CodePage page) const;
|
void encodeWindows932(const U32String &src);
|
||||||
|
void encodeWindows949(const U32String &src);
|
||||||
|
void encodeWindows950(const U32String &src, bool translit = true);
|
||||||
|
void encodeOneByte(const U32String &src, CodePage page, bool translit = true);
|
||||||
|
void encodeInternal(const U32String &src, CodePage page);
|
||||||
|
void translitChar(U32String::value_type point);
|
||||||
|
|
||||||
|
friend class U32String;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Append two strings to form a new (temp) string
|
// Append two strings to form a new (temp) string
|
||||||
|
|
|
@ -1735,24 +1735,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual bool isConnectionLimited();
|
virtual bool isConnectionLimited();
|
||||||
|
|
||||||
|
//@}
|
||||||
protected:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This allows derived classes to implement encoding conversion using platform
|
|
||||||
* specific API.
|
|
||||||
* This method shouldn't be called directly. Use Common::Encoding instead.
|
|
||||||
*
|
|
||||||
* @param to Encoding to convert the string to
|
|
||||||
* @param from Encoding to convert the string from
|
|
||||||
* @param string The string that should be converted
|
|
||||||
* @param length Size of the string in bytes
|
|
||||||
*
|
|
||||||
* @return Converted string, which must be freed by the caller (using free()
|
|
||||||
* and not delete[]), or nullptr if the conversion isn't possible.
|
|
||||||
*/
|
|
||||||
virtual char *convertEncoding(const char *to, const char *from, const char *string, size_t length) { return nullptr; }
|
|
||||||
/** @} */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
#define BACKENDS_TEXT_TO_SPEECH_ABSTRACT_H
|
#define BACKENDS_TEXT_TO_SPEECH_ABSTRACT_H
|
||||||
|
|
||||||
#include "common/scummsys.h"
|
#include "common/scummsys.h"
|
||||||
#include "common/encoding.h"
|
#include "common/str.h"
|
||||||
|
|
||||||
#if defined(USE_TTS)
|
#if defined(USE_TTS)
|
||||||
|
|
||||||
|
@ -183,11 +183,8 @@ public:
|
||||||
* Says the given string, but strings can have a custom charset here.
|
* Says the given string, but strings can have a custom charset here.
|
||||||
* It will convert to UTF-32 before passing along to the intended method.
|
* It will convert to UTF-32 before passing along to the intended method.
|
||||||
*/
|
*/
|
||||||
bool say(const String &str, Action action, String charset = "UTF-8") {
|
bool say(const String &str, Action action, CodePage charset = kUtf8) {
|
||||||
uint32 *res = (uint32 *)Encoding::convert("UTF-32", charset, str);
|
U32String textToSpeak(str, charset);
|
||||||
U32String textToSpeak(res);
|
|
||||||
free(res);
|
|
||||||
|
|
||||||
return say(textToSpeak, action);
|
return say(textToSpeak, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +202,7 @@ public:
|
||||||
* @param charset The encoding of the string. It will be converted to UTF-32.
|
* @param charset The encoding of the string. It will be converted to UTF-32.
|
||||||
* It will use UTF-8 by default.
|
* It will use UTF-8 by default.
|
||||||
*/
|
*/
|
||||||
bool say(const String &str, String charset = "UTF-8") {
|
bool say(const String &str, CodePage charset = kUtf8) {
|
||||||
return say(str, INTERRUPT_NO_REPEAT, charset);
|
return say(str, INTERRUPT_NO_REPEAT, charset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,26 +27,26 @@
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
|
|
||||||
U32String::U32String(const char *str) : BaseString<u32char_type_t>() {
|
U32String::U32String(const char *str, Common::CodePage page) : BaseString<u32char_type_t>() {
|
||||||
if (str == nullptr) {
|
if (str == nullptr) {
|
||||||
_storage[0] = 0;
|
_storage[0] = 0;
|
||||||
_size = 0;
|
_size = 0;
|
||||||
} else {
|
} else {
|
||||||
initWithCStr(str, strlen(str));
|
decodeInternal(str, strlen(str), page);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
U32String::U32String(const char *str, uint32 len) : BaseString<u32char_type_t>() {
|
U32String::U32String(const char *str, uint32 len, Common::CodePage page) : BaseString<u32char_type_t>() {
|
||||||
initWithCStr(str, len);
|
decodeInternal(str, len, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
U32String::U32String(const char *beginP, const char *endP) : BaseString<u32char_type_t>() {
|
U32String::U32String(const char *beginP, const char *endP, Common::CodePage page) : BaseString<u32char_type_t>() {
|
||||||
assert(endP >= beginP);
|
assert(endP >= beginP);
|
||||||
initWithCStr(beginP, endP - beginP);
|
decodeInternal(beginP, endP - beginP, page);
|
||||||
}
|
}
|
||||||
|
|
||||||
U32String::U32String(const String &str) : BaseString<u32char_type_t>() {
|
U32String::U32String(const String &str, Common::CodePage page) : BaseString<u32char_type_t>() {
|
||||||
initWithCStr(str.c_str(), str.size());
|
decodeInternal(str.c_str(), str.size(), page);
|
||||||
}
|
}
|
||||||
|
|
||||||
U32String &U32String::operator=(const U32String &str) {
|
U32String &U32String::operator=(const U32String &str) {
|
||||||
|
@ -56,7 +56,7 @@ U32String &U32String::operator=(const U32String &str) {
|
||||||
|
|
||||||
U32String &U32String::operator=(const String &str) {
|
U32String &U32String::operator=(const String &str) {
|
||||||
clear();
|
clear();
|
||||||
initWithCStr(str.c_str(), str.size());
|
decodeInternal(str.c_str(), str.size(), Common::kUtf8);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ U32String &U32String::operator=(const value_type *str) {
|
||||||
|
|
||||||
U32String &U32String::operator=(const char *str) {
|
U32String &U32String::operator=(const char *str) {
|
||||||
clear();
|
clear();
|
||||||
initWithCStr(str, strlen(str));
|
decodeInternal(str, strlen(str), Common::kUtf8);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,16 +131,12 @@ U32String U32String::substr(size_t pos, size_t len) const {
|
||||||
return U32String(_str + pos, MIN((size_t)_size - pos, len));
|
return U32String(_str + pos, MIN((size_t)_size - pos, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
void U32String::insertString(const char *s, uint32 p) {
|
void U32String::insertString(const char *s, uint32 p, CodePage page) {
|
||||||
while (*s != '\0') {
|
insertString(U32String(s, page), p);
|
||||||
BaseString<u32char_type_t>::insertChar(*s++, p++);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void U32String::insertString(const String &s, uint32 p) {
|
void U32String::insertString(const String &s, uint32 p, CodePage page) {
|
||||||
for (uint32 i = 0; i < s.size(); ++i) {
|
insertString(U32String(s, page), p);
|
||||||
BaseString<u32char_type_t>::insertChar(s[i], p++);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
U32String U32String::format(U32String fmt, ...) {
|
U32String U32String::format(U32String fmt, ...) {
|
||||||
|
|
|
@ -84,16 +84,16 @@ public:
|
||||||
U32String(const U32String &str) : BaseString<u32char_type_t>(str) {}
|
U32String(const U32String &str) : BaseString<u32char_type_t>(str) {}
|
||||||
|
|
||||||
/** Construct a new string from the given NULL-terminated C string. */
|
/** Construct a new string from the given NULL-terminated C string. */
|
||||||
explicit U32String(const char *str);
|
explicit U32String(const char *str, CodePage page = kUtf8);
|
||||||
|
|
||||||
/** Construct a new string containing exactly len characters read from address str. */
|
/** Construct a new string containing exactly len characters read from address str. */
|
||||||
U32String(const char *str, uint32 len);
|
U32String(const char *str, uint32 len, CodePage page = kUtf8);
|
||||||
|
|
||||||
/** Construct a new string containing the characters between beginP (including) and endP (excluding). */
|
/** Construct a new string containing the characters between beginP (including) and endP (excluding). */
|
||||||
U32String(const char *beginP, const char *endP);
|
U32String(const char *beginP, const char *endP, CodePage page = kUtf8);
|
||||||
|
|
||||||
/** Construct a copy of the given string. */
|
/** Construct a copy of the given string. */
|
||||||
U32String(const String &str);
|
U32String(const String &str, CodePage page = kUtf8);
|
||||||
|
|
||||||
U32String &operator=(const U32String &str);
|
U32String &operator=(const U32String &str);
|
||||||
U32String &operator=(const String &str);
|
U32String &operator=(const String &str);
|
||||||
|
@ -130,8 +130,8 @@ public:
|
||||||
static char* itoa(int num, char* str, int base);
|
static char* itoa(int num, char* str, int base);
|
||||||
|
|
||||||
using BaseString<value_type>::insertString;
|
using BaseString<value_type>::insertString;
|
||||||
void insertString(const char *s, uint32 p);
|
void insertString(const char *s, uint32 p, CodePage page = kUtf8);
|
||||||
void insertString(const String &s, uint32 p);
|
void insertString(const String &s, uint32 p, CodePage page = kUtf8);
|
||||||
|
|
||||||
/** Return a substring of this string */
|
/** Return a substring of this string */
|
||||||
U32String substr(size_t pos = 0, size_t len = npos) const;
|
U32String substr(size_t pos = 0, size_t len = npos) const;
|
||||||
|
@ -140,9 +140,24 @@ public:
|
||||||
return (const uint32 *) _str;
|
return (const uint32 *) _str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Common::U32String decodeUTF16BE(const uint16 *start, uint len);
|
||||||
|
static Common::U32String decodeUTF16LE(const uint16 *start, uint len);
|
||||||
|
static Common::U32String decodeUTF16Native(const uint16 *start, uint len);
|
||||||
|
|
||||||
|
/* Transform U32String into UTF-16 representation. The result must be freed. */
|
||||||
|
uint16 *encodeUTF16BE(uint *len = nullptr) const;
|
||||||
|
uint16 *encodeUTF16LE(uint *len = nullptr) const;
|
||||||
|
uint16 *encodeUTF16Native(uint *len = nullptr) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void encodeUTF8(String &dst) const;
|
void decodeInternal(const char *str, uint32 len, CodePage page);
|
||||||
void encodeOneByte(String &dst, CodePage page) const;
|
void decodeOneByte(const char *str, uint32 len, CodePage page);
|
||||||
|
void decodeWindows932(const char *src, uint32 len);
|
||||||
|
void decodeWindows949(const char *src, uint32 len);
|
||||||
|
void decodeWindows950(const char *src, uint32 len);
|
||||||
|
void decodeUTF8(const char *str, uint32 len);
|
||||||
|
|
||||||
|
friend class String;
|
||||||
};
|
};
|
||||||
|
|
||||||
U32String operator+(const U32String &x, const U32String &y);
|
U32String operator+(const U32String &x, const U32String &y);
|
||||||
|
|
91
configure
vendored
91
configure
vendored
|
@ -171,7 +171,6 @@ _taskbar=auto
|
||||||
_updates=no
|
_updates=no
|
||||||
_libunity=auto
|
_libunity=auto
|
||||||
_dialogs=auto
|
_dialogs=auto
|
||||||
_iconv=auto
|
|
||||||
_tts=auto
|
_tts=auto
|
||||||
_gtk=auto
|
_gtk=auto
|
||||||
_fribidi=auto
|
_fribidi=auto
|
||||||
|
@ -1181,9 +1180,6 @@ Optional Libraries:
|
||||||
--with-libcurl-prefix=DIR prefix where libcurl is installed (optional)
|
--with-libcurl-prefix=DIR prefix where libcurl is installed (optional)
|
||||||
--disable-libcurl disable libcurl networking library [autodetect]
|
--disable-libcurl disable libcurl networking library [autodetect]
|
||||||
|
|
||||||
--with-iconv-prefix=DIR prefix where libiconv is installed (optional)
|
|
||||||
--disable-iconv disable libiconv encoding conversion library [autodetect]
|
|
||||||
|
|
||||||
--with-discord-prefix=DIR prefix where discord-rpc is installed (optional)
|
--with-discord-prefix=DIR prefix where discord-rpc is installed (optional)
|
||||||
--disable-discord disable Discord rich presence integration [autodetect]
|
--disable-discord disable Discord rich presence integration [autodetect]
|
||||||
|
|
||||||
|
@ -1349,8 +1345,6 @@ for ac_option in $@; do
|
||||||
--disable-eventrecorder) _eventrec=no ;;
|
--disable-eventrecorder) _eventrec=no ;;
|
||||||
--enable-text-console) _text_console=yes ;;
|
--enable-text-console) _text_console=yes ;;
|
||||||
--disable-text-console) _text_console=no ;;
|
--disable-text-console) _text_console=no ;;
|
||||||
--enable-iconv) _iconv=yes ;;
|
|
||||||
--disable-iconv) _iconv=no ;;
|
|
||||||
--with-fluidsynth-prefix=*)
|
--with-fluidsynth-prefix=*)
|
||||||
arg=`echo $ac_option | cut -d '=' -f 2`
|
arg=`echo $ac_option | cut -d '=' -f 2`
|
||||||
FLUIDSYNTH_CFLAGS="-I$arg/include"
|
FLUIDSYNTH_CFLAGS="-I$arg/include"
|
||||||
|
@ -1470,11 +1464,6 @@ for ac_option in $@; do
|
||||||
GLEW_CFLAGS="-I$arg/include"
|
GLEW_CFLAGS="-I$arg/include"
|
||||||
GLEW_LIBS="-L$arg/lib"
|
GLEW_LIBS="-L$arg/lib"
|
||||||
;;
|
;;
|
||||||
--with-iconv-prefix=*)
|
|
||||||
arg=`echo $ac_option | cut -d '=' -f 2`
|
|
||||||
ICONV_CFLAGS="-I$arg/include"
|
|
||||||
ICONV_LIBS="-L$arg/lib"
|
|
||||||
;;
|
|
||||||
--with-discord-prefix=*)
|
--with-discord-prefix=*)
|
||||||
arg=`echo $ac_option | cut -d '=' -f 2`
|
arg=`echo $ac_option | cut -d '=' -f 2`
|
||||||
DISCORD_CFLAGS="-I$arg/include"
|
DISCORD_CFLAGS="-I$arg/include"
|
||||||
|
@ -5516,86 +5505,6 @@ if test -n "$LIBS_3D" ; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Check for iconv
|
|
||||||
#
|
|
||||||
echo_n "Checking whether iconv.h is present... "
|
|
||||||
if test "$_iconv" = auto ; then
|
|
||||||
_iconv=no
|
|
||||||
cat > $TMPC << EOF
|
|
||||||
#include <iconv.h>
|
|
||||||
int main(int, char **) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
cc_check $ICONV_CFLAGS $ICONV_LIBS && _iconv=yes
|
|
||||||
fi
|
|
||||||
|
|
||||||
create_iconv_test() {
|
|
||||||
cat > $TMPC << EOF
|
|
||||||
#include <iconv.h>
|
|
||||||
int main(int, char **) {
|
|
||||||
iconv_t iconv = iconv_open("UTF-32", "SJIS");
|
|
||||||
iconv_close(iconv);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
}
|
|
||||||
echo "$_iconv"
|
|
||||||
|
|
||||||
if test "$_iconv" = yes ; then
|
|
||||||
echo_n "Checking whether iconv needs linking against libiconv... "
|
|
||||||
|
|
||||||
needs_iconvlib='auto'
|
|
||||||
create_iconv_test
|
|
||||||
cc_check $ICONV_CFLAGS $ICONV_LIBS -liconv && needs_iconvlib='yes'
|
|
||||||
# We do check linking without -liconv here too, just in case
|
|
||||||
# it would fail otherwise too
|
|
||||||
create_iconv_test
|
|
||||||
cc_check $ICONV_CFLAGS $ICONV_LIBS && needs_iconvlib='no'
|
|
||||||
|
|
||||||
if test "$needs_iconvlib" = auto ; then
|
|
||||||
_iconv=no
|
|
||||||
echo "does not link at all"
|
|
||||||
else
|
|
||||||
if test "$needs_iconvlib" = yes ; then
|
|
||||||
append_var ICONV_LIBS "-liconv"
|
|
||||||
fi
|
|
||||||
echo "$needs_iconvlib"
|
|
||||||
|
|
||||||
echo_n "Checking signature of iconv... "
|
|
||||||
uses_const=no
|
|
||||||
|
|
||||||
cat > $TMPC << EOF
|
|
||||||
#include <iconv.h>
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
iconv_t iconvP;
|
|
||||||
const char **inbuf = 0;
|
|
||||||
iconv(iconvP, inbuf, 0, 0, 0);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
cc_check $ICONV_CFLAGS $ICONV_LIBS && uses_const=yes
|
|
||||||
|
|
||||||
if test "$uses_const" = yes ; then
|
|
||||||
echo "iconv_t, const char **, size_t *, char **, size_t *"
|
|
||||||
else
|
|
||||||
echo "iconv_t, char **, size_t *, char **, size_t *"
|
|
||||||
fi
|
|
||||||
|
|
||||||
define_in_config_if_yes "$uses_const" 'ICONV_USES_CONST'
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test "$_iconv" = yes ; then
|
|
||||||
append_var LIBS "$ICONV_LIBS"
|
|
||||||
append_var INCLUDES "$ICONV_CFLAGS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echocheck "iconv"
|
|
||||||
define_in_config_if_yes "$_iconv" 'USE_ICONV'
|
|
||||||
echo "$_iconv"
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Check for Linux CD-ROM support
|
# Check for Linux CD-ROM support
|
||||||
#
|
#
|
||||||
|
|
|
@ -45,6 +45,12 @@ create_drascula (sev)
|
||||||
and Italian. This tool is used to create the drascula.dat file.
|
and Italian. This tool is used to create the drascula.dat file.
|
||||||
|
|
||||||
|
|
||||||
|
create_encodings (phcoder)
|
||||||
|
--------------
|
||||||
|
Transforms CJK tables from unicode consortium format to the format
|
||||||
|
used by ScummVM
|
||||||
|
|
||||||
|
|
||||||
create_hugo (Strangerke)
|
create_hugo (Strangerke)
|
||||||
-----------
|
-----------
|
||||||
Creates hugo.dat file which contains all kinds of static data contained
|
Creates hugo.dat file which contains all kinds of static data contained
|
||||||
|
|
7998
devtools/create_encoding/CP932.TXT
Normal file
7998
devtools/create_encoding/CP932.TXT
Normal file
File diff suppressed because it is too large
Load diff
17322
devtools/create_encoding/CP949.TXT
Normal file
17322
devtools/create_encoding/CP949.TXT
Normal file
File diff suppressed because it is too large
Load diff
13777
devtools/create_encoding/CP950.TXT
Normal file
13777
devtools/create_encoding/CP950.TXT
Normal file
File diff suppressed because it is too large
Load diff
66
devtools/create_encoding/create_encoging.py
Executable file
66
devtools/create_encoding/create_encoging.py
Executable file
|
@ -0,0 +1,66 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
# encoding: utf-8
|
||||||
|
|
||||||
|
import struct
|
||||||
|
|
||||||
|
def processtable(inputfilename, outfile, highrange, lowrange):
|
||||||
|
with open(inputfilename) as f:
|
||||||
|
res = dict(((x << 8) | y, 0) for x in highrange for y in lowrange)
|
||||||
|
|
||||||
|
for line in f:
|
||||||
|
if line.startswith('#'):
|
||||||
|
continue
|
||||||
|
splits = line.split()
|
||||||
|
if len(splits[0]) <= 5:
|
||||||
|
continue
|
||||||
|
key = int(splits[0], 16)
|
||||||
|
val = int(splits[1], 16)
|
||||||
|
high = (key >> 8) & 0xff
|
||||||
|
low = key & 0xff
|
||||||
|
if high not in highrange or low not in lowrange:
|
||||||
|
continue
|
||||||
|
res[key] = val
|
||||||
|
|
||||||
|
for (k, v) in sorted(res.items()):
|
||||||
|
outfile.write(struct.pack("<H", v))
|
||||||
|
|
||||||
|
|
||||||
|
encdat = open("encoding.dat", "wb")
|
||||||
|
encdat.write(b'SCVMENCD')
|
||||||
|
# version
|
||||||
|
encdat.write(struct.pack("<i", 0))
|
||||||
|
|
||||||
|
HIGH = 'high'
|
||||||
|
LOW = 'low'
|
||||||
|
FILE = 'file'
|
||||||
|
|
||||||
|
tables = [
|
||||||
|
{
|
||||||
|
FILE: "CP932.TXT",
|
||||||
|
HIGH: range(0x81, 0x85) + range(0x87, 0xa0) + range(0xe0, 0xef) + range(0xfa, 0xfd),
|
||||||
|
LOW: range(0x40, 0x100)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
FILE: "CP949.TXT",
|
||||||
|
HIGH: range(0x81, 0xFF),
|
||||||
|
LOW: range(0x41, 0x5b) + range(0x61, 0x7b) + range(0x81, 0xFF)
|
||||||
|
},
|
||||||
|
{
|
||||||
|
FILE: "CP950.TXT",
|
||||||
|
HIGH: range(0xA1, 0xFA),
|
||||||
|
LOW: range(0x40, 0x7f) + range(0xa1, 0xff)
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
# number of tables
|
||||||
|
encdat.write(struct.pack("<i", len(tables)))
|
||||||
|
|
||||||
|
curofs = 16 + 4 * len(tables)
|
||||||
|
|
||||||
|
for v in tables:
|
||||||
|
encdat.write(struct.pack("<i", curofs))
|
||||||
|
curofs += len(v[HIGH]) * len(v[LOW]) * 2
|
||||||
|
|
||||||
|
for v in tables:
|
||||||
|
processtable(v[FILE], encdat, v[HIGH], v[LOW])
|
||||||
|
|
|
@ -822,6 +822,7 @@ XcodeProvider::ValueList& XcodeProvider::getResourceFiles() const {
|
||||||
files.push_back("dists/engine-data/cryo.dat");
|
files.push_back("dists/engine-data/cryo.dat");
|
||||||
files.push_back("dists/engine-data/cryomni3d.dat");
|
files.push_back("dists/engine-data/cryomni3d.dat");
|
||||||
files.push_back("dists/engine-data/drascula.dat");
|
files.push_back("dists/engine-data/drascula.dat");
|
||||||
|
files.push_back("dists/engine-data/encoding.dat");
|
||||||
files.push_back("dists/engine-data/fonts.dat");
|
files.push_back("dists/engine-data/fonts.dat");
|
||||||
files.push_back("dists/engine-data/hugo.dat");
|
files.push_back("dists/engine-data/hugo.dat");
|
||||||
files.push_back("dists/engine-data/kyra.dat");
|
files.push_back("dists/engine-data/kyra.dat");
|
||||||
|
|
|
@ -15,6 +15,9 @@ Those informations were stored in the original executables.
|
||||||
drascula.dat:
|
drascula.dat:
|
||||||
This file contains essential game data used by Drascula engine.
|
This file contains essential game data used by Drascula engine.
|
||||||
|
|
||||||
|
encoding.dat:
|
||||||
|
This file contains character mapping for CJK encodings to unicode.
|
||||||
|
|
||||||
fonts.dat:
|
fonts.dat:
|
||||||
This file contains set of free TTF fonts used by Glk, ZVision, Wintermute engines and
|
This file contains set of free TTF fonts used by Glk, ZVision, Wintermute engines and
|
||||||
our GUI.
|
our GUI.
|
||||||
|
|
BIN
dists/engine-data/encoding.dat
Normal file
BIN
dists/engine-data/encoding.dat
Normal file
Binary file not shown.
|
@ -9,6 +9,7 @@ f 0644 root sys usr/ScummVM/share/scummvm/access.dat access.dat scummvm.sw.eoe
|
||||||
f 0644 root sys usr/ScummVM/share/scummvm/cryo.dat cryo.dat scummvm.sw.eoe
|
f 0644 root sys usr/ScummVM/share/scummvm/cryo.dat cryo.dat scummvm.sw.eoe
|
||||||
f 0644 root sys usr/ScummVM/share/scummvm/cryomni3d.dat cryomni3d.dat scummvm.sw.eoe
|
f 0644 root sys usr/ScummVM/share/scummvm/cryomni3d.dat cryomni3d.dat scummvm.sw.eoe
|
||||||
f 0644 root sys usr/ScummVM/share/scummvm/drascula.dat drascula.dat scummvm.sw.eoe
|
f 0644 root sys usr/ScummVM/share/scummvm/drascula.dat drascula.dat scummvm.sw.eoe
|
||||||
|
f 0644 root sys usr/ScummVM/share/scummvm/encoding.dat encoding.dat scummvm.sw.eoe
|
||||||
f 0644 root sys usr/ScummVM/share/scummvm/fonts.dat fonts.dat scummvm.sw.eoe
|
f 0644 root sys usr/ScummVM/share/scummvm/fonts.dat fonts.dat scummvm.sw.eoe
|
||||||
f 0644 root sys usr/ScummVM/share/scummvm/hugo.dat hugo.dat scummvm.sw.eoe
|
f 0644 root sys usr/ScummVM/share/scummvm/hugo.dat hugo.dat scummvm.sw.eoe
|
||||||
f 0644 root sys usr/ScummVM/share/scummvm/kyra.dat kyra.dat scummvm.sw.eoe
|
f 0644 root sys usr/ScummVM/share/scummvm/kyra.dat kyra.dat scummvm.sw.eoe
|
||||||
|
|
|
@ -54,6 +54,7 @@ cryomni3d.dat FILE "dists/engine-data/cryomni3d.dat"
|
||||||
#if PLUGIN_ENABLED_STATIC(DRASCULA)
|
#if PLUGIN_ENABLED_STATIC(DRASCULA)
|
||||||
drascula.dat FILE "dists/engine-data/drascula.dat"
|
drascula.dat FILE "dists/engine-data/drascula.dat"
|
||||||
#endif
|
#endif
|
||||||
|
encoding.dat FILE "dists/engine-data/encoding.dat"
|
||||||
#if PLUGIN_ENABLED_STATIC(HUGO)
|
#if PLUGIN_ENABLED_STATIC(HUGO)
|
||||||
hugo.dat FILE "dists/engine-data/hugo.dat"
|
hugo.dat FILE "dists/engine-data/hugo.dat"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -805,7 +805,7 @@ void SoundManager::startSpeech(int rep, int character, int typ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
_ttsMan->setPitch(pitch);
|
_ttsMan->setPitch(pitch);
|
||||||
_ttsMan->say(_vm->getString(rep + kDialogStringIndex), "CP850");
|
_ttsMan->say(_vm->getString(rep + kDialogStringIndex), Common::kDos850);
|
||||||
#endif // USE_TTS
|
#endif // USE_TTS
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "engines/myst3/state.h"
|
#include "engines/myst3/state.h"
|
||||||
|
|
||||||
#include "common/archive.h"
|
#include "common/archive.h"
|
||||||
#include "common/iconv.h"
|
|
||||||
|
|
||||||
#include "graphics/fontman.h"
|
#include "graphics/fontman.h"
|
||||||
#include "graphics/font.h"
|
#include "graphics/font.h"
|
||||||
|
@ -244,17 +243,16 @@ void FontSubtitles::createTexture() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_ICONV
|
|
||||||
/** Return an encoding from a GDI Charset as provided to CreateFont */
|
/** Return an encoding from a GDI Charset as provided to CreateFont */
|
||||||
static Common::IconvEncoding getEncodingFromCharsetCode(uint32 gdiCharset) {
|
static Common::CodePage getEncodingFromCharsetCode(uint32 gdiCharset) {
|
||||||
static const struct {
|
static const struct {
|
||||||
uint32 charset;
|
uint32 charset;
|
||||||
Common::IconvEncoding encoding;
|
Common::CodePage encoding;
|
||||||
} codepages[] = {
|
} codepages[] = {
|
||||||
{ 128, Common::kEncodingCP932 }, // SHIFTJIS_CHARSET
|
{ 128, Common::kWindows932 }, // SHIFTJIS_CHARSET
|
||||||
{ 177, Common::kEncodingCP1255 }, // HEBREW_CHARSET
|
{ 177, Common::kWindows1255 }, // HEBREW_CHARSET
|
||||||
{ 204, Common::kEncodingCP1251 }, // RUSSIAN_CHARSET
|
{ 204, Common::kWindows1251 }, // RUSSIAN_CHARSET
|
||||||
{ 238, Common::kEncodingMacCentralEurope } // EASTEUROPE_CHARSET
|
{ 238, Common::kMacCentralEurope } // EASTEUROPE_CHARSET
|
||||||
};
|
};
|
||||||
|
|
||||||
for (uint i = 0; i < ARRAYSIZE(codepages); i++) {
|
for (uint i = 0; i < ARRAYSIZE(codepages); i++) {
|
||||||
|
@ -265,7 +263,6 @@ static Common::IconvEncoding getEncodingFromCharsetCode(uint32 gdiCharset) {
|
||||||
|
|
||||||
error("Unknown font charset code '%d'", gdiCharset);
|
error("Unknown font charset code '%d'", gdiCharset);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void FontSubtitles::drawToTexture(const Phrase *phrase) {
|
void FontSubtitles::drawToTexture(const Phrase *phrase) {
|
||||||
const Graphics::Font *font;
|
const Graphics::Font *font;
|
||||||
|
@ -288,13 +285,9 @@ void FontSubtitles::drawToTexture(const Phrase *phrase) {
|
||||||
if (_fontCharsetCode == 0) {
|
if (_fontCharsetCode == 0) {
|
||||||
font->drawString(_surface, phrase->string, 0, _singleLineTop * _scale, _surface->w, 0xFFFFFFFF, Graphics::kTextAlignCenter, 0, false);
|
font->drawString(_surface, phrase->string, 0, _singleLineTop * _scale, _surface->w, 0xFFFFFFFF, Graphics::kTextAlignCenter, 0, false);
|
||||||
} else {
|
} else {
|
||||||
#ifdef USE_ICONV
|
Common::CodePage encoding = getEncodingFromCharsetCode(_fontCharsetCode);
|
||||||
Common::IconvEncoding encoding = getEncodingFromCharsetCode(_fontCharsetCode);
|
Common::U32String unicode = Common::U32String(phrase->string, encoding);
|
||||||
Common::U32String unicode = Common::convertToU32String(encoding, phrase->string);
|
|
||||||
font->drawString(_surface, unicode, 0, _singleLineTop * _scale, _surface->w, 0xFFFFFFFF, Graphics::kTextAlignCenter, 0, false);
|
font->drawString(_surface, unicode, 0, _singleLineTop * _scale, _surface->w, 0xFFFFFFFF, Graphics::kTextAlignCenter, 0, false);
|
||||||
#else
|
|
||||||
warning("Unable to display charset '%d' subtitles, iconv support is not compiled in.", _fontCharsetCode);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the texture
|
// Update the texture
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "common/encoding.h"
|
|
||||||
#include "common/savefile.h"
|
#include "common/savefile.h"
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "common/events.h"
|
#include "common/events.h"
|
||||||
|
@ -467,15 +466,15 @@ const Common::U32String InfoDialog::queryResString(int stringno) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::String convertFromCodePage;
|
Common::CodePage convertFromCodePage = Common::kCodePageInvalid;
|
||||||
if (_vm->_language == Common::KO_KOR)
|
if (_vm->_language == Common::KO_KOR)
|
||||||
convertFromCodePage = "cp949";
|
convertFromCodePage = Common::kWindows949;
|
||||||
else if (_vm->_language == Common::JA_JPN)
|
else if (_vm->_language == Common::JA_JPN)
|
||||||
convertFromCodePage = "shift_jis";
|
convertFromCodePage = Common::kWindows932;
|
||||||
else if (_vm->_language == Common::ZH_TWN || _vm->_language == Common::ZH_CNA)
|
else if (_vm->_language == Common::ZH_TWN || _vm->_language == Common::ZH_CNA)
|
||||||
convertFromCodePage = "big5";
|
convertFromCodePage = Common::kWindows950;
|
||||||
|
|
||||||
return convertFromCodePage.empty() ? _(tmp) : U32String((const Common::U32String::value_type*)Common::Encoding::convert("utf-32", convertFromCodePage, tmp));
|
return convertFromCodePage == Common::kCodePageInvalid ? _(tmp) : U32String(tmp, convertFromCodePage);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark -
|
#pragma mark -
|
||||||
|
|
|
@ -1,897 +0,0 @@
|
||||||
/* ScummVM - Graphic Adventure Engine
|
|
||||||
*
|
|
||||||
* ScummVM is the legal property of its developers, whose names
|
|
||||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
||||||
* file distributed with this source distribution.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "common/encoding.h"
|
|
||||||
#include "common/system.h"
|
|
||||||
#include "engines/testbed/encoding.h"
|
|
||||||
|
|
||||||
namespace Testbed {
|
|
||||||
|
|
||||||
TestExitStatus Encodingtests::testConversionUnicodeMachineEndian() {
|
|
||||||
Testsuite::displayMessage("Encoding conversion tests.\nTo test iconv conversion, compile with --enable-iconv.\nTo test backend conversion, compile with --disable-iconv.\nSome tests may fail without iconv, because some backends support only a handful of conversions.");
|
|
||||||
Common::String info = "Unicode conversion test. Multiple conversions between UTF-8, UTF-16 and UTF-32 in the default machinge endian will be performed.";
|
|
||||||
|
|
||||||
Common::Point pt(0, 100);
|
|
||||||
Testsuite::writeOnScreen("Testing unicode conversion in machine native endianness.", pt);
|
|
||||||
|
|
||||||
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
|
|
||||||
Testsuite::logPrintf("Info! Skipping test : testConversionUnicodeMachineEndian\n");
|
|
||||||
return kTestSkipped;
|
|
||||||
}
|
|
||||||
// |dolar| cent | euro |
|
|
||||||
unsigned char utf8[] = {0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0};
|
|
||||||
#ifdef SCUMM_BIG_ENDIAN
|
|
||||||
//| dolar | cent | euro |
|
|
||||||
unsigned char utf16be[] = {0, 0x24, 0, 0xA2, 0x20, 0xAC, 0, 0};
|
|
||||||
//| dolar | cent | euro
|
|
||||||
unsigned char utf32be[] = {0, 0, 0, 0x24, 0, 0, 0, 0xA2, 0, 0, 0x20, 0xAC, 0, 0, 0, 0};
|
|
||||||
|
|
||||||
unsigned char *utf16 = utf16be;
|
|
||||||
unsigned char *utf32 = utf32be;
|
|
||||||
#else
|
|
||||||
//| dolar | cent | euro |
|
|
||||||
unsigned char utf16le[] = {0x24, 0, 0xA2, 0, 0xAC, 0x20, 0, 0};
|
|
||||||
//| dolar | cent | euro
|
|
||||||
unsigned char utf32le[] = {0x24, 0, 0, 0, 0xA2, 0, 0, 0, 0xAC, 0x20, 0, 0, 0, 0, 0, 0};
|
|
||||||
|
|
||||||
unsigned char *utf16 = utf16le;
|
|
||||||
unsigned char *utf32 = utf32le;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// UTF16 to UTF8
|
|
||||||
Common::Encoding converter("UTF-8", "UTF-16");
|
|
||||||
|
|
||||||
char *result = converter.convert((char *) utf16, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-8", "UTF-16", (char *) utf16, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF32 to UTF8
|
|
||||||
converter.setFrom("UTF-32");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf32, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-8", "UTF-32", (char *) utf32, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF32 to UTF16
|
|
||||||
converter.setTo("UTF-16");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf32, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-16", "UTF-32", (char *) utf32, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF8 to UTF16
|
|
||||||
converter.setFrom("UTF-8");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-16", "UTF-8", (char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF8 to UTF32
|
|
||||||
converter.setTo("UTF-32");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-32", "UTF-8", (char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF16 to UTF32
|
|
||||||
converter.setFrom("UTF-16");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf16, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-32", "UTF-16", (char *) utf16, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
return kTestPassed;
|
|
||||||
}
|
|
||||||
|
|
||||||
TestExitStatus Encodingtests::testConversionUnicodeBigEndian() {
|
|
||||||
Common::String info = "Unicode conversion test. Multiple conversions between UTF-8, UTF-16 and UTF-32 in big endian will be performed.";
|
|
||||||
|
|
||||||
Common::Point pt(0, 100);
|
|
||||||
Testsuite::writeOnScreen("Testing unicode conversion in big endian.", pt);
|
|
||||||
|
|
||||||
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
|
|
||||||
Testsuite::logPrintf("Info! Skipping test : testConversionUnicodeBigEndian\n");
|
|
||||||
return kTestSkipped;
|
|
||||||
}
|
|
||||||
// |dolar| cent | euro |
|
|
||||||
unsigned char utf8[] = {0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0};
|
|
||||||
//| dolar | cent | euro |
|
|
||||||
unsigned char utf16be[] = {0, 0x24, 0, 0xA2, 0x20, 0xAC, 0, 0};
|
|
||||||
//| dolar | cent | euro
|
|
||||||
unsigned char utf32be[] = {0, 0, 0, 0x24, 0, 0, 0, 0xA2, 0, 0, 0x20, 0xAC, 0, 0, 0, 0};
|
|
||||||
|
|
||||||
#if SCUMM_BIG_ENDIAN
|
|
||||||
//| dolar | cent | euro |
|
|
||||||
unsigned char utf16[] = {0, 0x24, 0, 0xA2, 0x20, 0xAC, 0, 0};
|
|
||||||
//| dolar | cent | euro
|
|
||||||
unsigned char utf32[] = {0, 0, 0, 0x24, 0, 0, 0, 0xA2, 0, 0, 0x20, 0xAC, 0, 0, 0, 0};
|
|
||||||
#else
|
|
||||||
//| dolar | cent | euro |
|
|
||||||
unsigned char utf16[] = {0x24, 0, 0xA2, 0, 0xAC, 0x20, 0, 0};
|
|
||||||
//| dolar | cent | euro
|
|
||||||
unsigned char utf32[] = {0x24, 0, 0, 0, 0xA2, 0, 0, 0, 0xAC, 0x20, 0, 0, 0, 0, 0, 0};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// UTF16 to UTF8
|
|
||||||
Common::Encoding converter("UTF-8", "UTF-16BE");
|
|
||||||
|
|
||||||
char *result = converter.convert((char *) utf16be, 6);
|
|
||||||
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-8", "UTF-16BE", (char *) utf16be, 6);
|
|
||||||
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF32 to UTF8
|
|
||||||
converter.setFrom("UTF-32BE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf32be, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-8", "UTF-32BE", (char *) utf32be, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF32 to UTF16
|
|
||||||
converter.setTo("UTF-16BE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf32be, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16be, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-16BE", "UTF-32BE", (char *) utf32be, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16be, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF8 to UTF16
|
|
||||||
converter.setFrom("UTF-8");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16be, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-16BE", "UTF-8", (char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16be, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF8 to UTF32
|
|
||||||
converter.setTo("UTF-32BE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32be, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-32BE", "UTF-8", (char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32be, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF16 to UTF32
|
|
||||||
converter.setFrom("UTF-16BE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf16be, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32be, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-32BE", "UTF-16BE", (char *) utf16be, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32be, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF16 to UTF16
|
|
||||||
converter.setFrom("UTF-16BE");
|
|
||||||
converter.setTo("UTF-16");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf16be, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16BE to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-16BE to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
converter.setFrom("UTF-16");
|
|
||||||
converter.setTo("UTF-16BE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf16, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-16BE conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16be, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-16BE conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF32 to UTF32
|
|
||||||
converter.setFrom("UTF-32BE");
|
|
||||||
converter.setTo("UTF-32");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf32be, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32BE to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-32BE to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
converter.setFrom("UTF-32");
|
|
||||||
converter.setTo("UTF-32BE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf32, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-32BE conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32be, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-32BE conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
return kTestPassed;
|
|
||||||
}
|
|
||||||
|
|
||||||
TestExitStatus Encodingtests::testConversionUnicodeLittleEndian() {
|
|
||||||
Common::String info = "Unicode conversion test. Multiple conversions between UTF-8, UTF-16 and UTF-32 in little endian will be performed.";
|
|
||||||
|
|
||||||
Common::Point pt(0, 100);
|
|
||||||
Testsuite::writeOnScreen("Testing unicode conversion in little endianness.", pt);
|
|
||||||
|
|
||||||
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
|
|
||||||
Testsuite::logPrintf("Info! Skipping test : testConversionUnicodeLittleEndian\n");
|
|
||||||
return kTestSkipped;
|
|
||||||
}
|
|
||||||
// |dolar| cent | euro |
|
|
||||||
unsigned char utf8[] = {0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0};
|
|
||||||
//| dolar | cent | euro |
|
|
||||||
unsigned char utf16le[] = {0x24, 0, 0xA2, 0, 0xAC, 0x20, 0, 0};
|
|
||||||
//| dolar | cent | euro
|
|
||||||
unsigned char utf32le[] = {0x24, 0, 0, 0, 0xA2, 0, 0, 0, 0xAC, 0x20, 0, 0, 0, 0, 0, 0};
|
|
||||||
|
|
||||||
#if SCUMM_BIG_ENDIAN
|
|
||||||
unsigned char utf16[] = {0, 0x24, 0, 0xA2, 0x20, 0xAC, 0, 0};
|
|
||||||
//| dolar | cent | euro
|
|
||||||
unsigned char utf32[] = {0, 0, 0, 0x24, 0, 0, 0, 0xA2, 0, 0, 0x20, 0xAC, 0, 0, 0, 0};
|
|
||||||
#else
|
|
||||||
//| dolar | cent | euro |
|
|
||||||
unsigned char utf16[] = {0x24, 0, 0xA2, 0, 0xAC, 0x20, 0, 0};
|
|
||||||
//| dolar | cent | euro
|
|
||||||
unsigned char utf32[] = {0x24, 0, 0, 0, 0xA2, 0, 0, 0, 0xAC, 0x20, 0, 0, 0, 0, 0, 0};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// UTF16 to UTF8
|
|
||||||
Common::Encoding converter("UTF-8", "UTF-16LE");
|
|
||||||
|
|
||||||
char *result = converter.convert((char *) utf16le, 6);
|
|
||||||
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-8", "UTF-16LE", (char *) utf16le, 6);
|
|
||||||
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF32 to UTF8
|
|
||||||
converter.setFrom("UTF-32LE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf32le, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-8", "UTF-32LE", (char *) utf32le, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 7)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-8 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF32 to UTF16
|
|
||||||
converter.setTo("UTF-16LE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf32le, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16le, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-16LE", "UTF-32LE", (char *) utf32le, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16le, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF8 to UTF16
|
|
||||||
converter.setFrom("UTF-8");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16le, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-16LE", "UTF-8", (char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16le, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF8 to UTF32
|
|
||||||
converter.setTo("UTF-32LE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32le, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-32LE", "UTF-8", (char *) utf8, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32le, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF16 to UTF32
|
|
||||||
converter.setFrom("UTF-16LE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf16le, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32le, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-32LE", "UTF-16LE", (char *) utf16le, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32le, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF16 to UTF16
|
|
||||||
converter.setFrom("UTF-16LE");
|
|
||||||
converter.setTo("UTF-16");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf16le, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16LE to UTF-16 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-16LE to UTF-16 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
converter.setFrom("UTF-16");
|
|
||||||
converter.setTo("UTF-16LE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf16, 6);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-16LE conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf16le, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-16 to UTF-16LE conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// UTF32 to UTF32
|
|
||||||
converter.setFrom("UTF-32LE");
|
|
||||||
converter.setTo("UTF-32");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf32le, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32LE to UTF-32 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-32LE to UTF-32 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
converter.setFrom("UTF-32");
|
|
||||||
converter.setTo("UTF-32LE");
|
|
||||||
|
|
||||||
result = converter.convert((char *) utf32, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-32LE conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf32le, 16)) {
|
|
||||||
Testsuite::logPrintf("UTF-32 to UTF-32LE conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
return kTestPassed;
|
|
||||||
}
|
|
||||||
|
|
||||||
TestExitStatus Encodingtests::testCyrillicTransliteration() {
|
|
||||||
Common::String info = "Cyrillic transliteration test. Multiple conversions between unicode, iso-8859-5 and ASCII will be performed.";
|
|
||||||
|
|
||||||
Common::Point pt(0, 100);
|
|
||||||
Testsuite::writeOnScreen("Testing Cyrillic transliteration", pt);
|
|
||||||
|
|
||||||
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
|
|
||||||
Testsuite::logPrintf("Info! Skipping test : testCyrillicTransliteration\n");
|
|
||||||
return kTestSkipped;
|
|
||||||
}
|
|
||||||
unsigned char utf8[] = {/* Z */0xD0, 0x97, /* d */ 0xD0, 0xB4, /* r */ 0xD1, 0x80, /* a */ 0xD0, 0xB0, /* v */ 0xD0, 0xB2, /* s */ 0xD1, 0x81, /* t */ 0xD1, 0x82, /* v */ 0xD0, 0xB2, /* u */ 0xD1, 0x83, /* j */ 0xD0, 0xB9, /* t */ 0xD1, 0x82, /* e */ 0xD0, 0xB5, 0};
|
|
||||||
unsigned char iso_8859_5[] = {0xB7, 0xD4, 0xE0, 0xD0, 0xD2, 0xE1, 0xE2, 0xD2, 0xE3, 0xD9, 0xE2, 0xD5, 0};
|
|
||||||
unsigned char ascii[] = "Zdravstvujte";
|
|
||||||
|
|
||||||
Common::Encoding converter("ASCII", "UTF-8");
|
|
||||||
char *result = converter.convert((char *)utf8, 24);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to ASCII conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, ascii, 13)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to ASCII conversion isn'differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
converter.setFrom("iso-8859-5");
|
|
||||||
result = converter.convert((char *)iso_8859_5, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("iso-8859-5 to ASCII conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, ascii, 13)) {
|
|
||||||
Testsuite::logPrintf("iso-8859-5 to ASCII conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
converter.setTo("UTF-8");
|
|
||||||
result = converter.convert((char *)iso_8859_5, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("iso-8859-5 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8, 25)) {
|
|
||||||
Testsuite::logPrintf("iso-8859-5 to UTF-differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
converter.setTo("iso-8859-5");
|
|
||||||
converter.setFrom("UTF-8");
|
|
||||||
result = converter.convert((char *)utf8, 24);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to iso-8859-5 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, iso_8859_5, 13)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to iso-8859-differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
// this should stay the same
|
|
||||||
converter.setFrom("ASCII");
|
|
||||||
result = converter.convert((char *)ascii, 12);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("ASCII to iso-8859-5 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, ascii, 13)) {
|
|
||||||
Testsuite::logPrintf("ASCII to iso-8859-5 conversion differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
return kTestPassed;
|
|
||||||
}
|
|
||||||
|
|
||||||
TestExitStatus Encodingtests::testOtherConversions() {
|
|
||||||
Common::String info = "Other conversions test. Some regular encoding conversions will be performed.";
|
|
||||||
|
|
||||||
Common::Point pt(0, 100);
|
|
||||||
Testsuite::writeOnScreen("Testing other encoding conversions", pt);
|
|
||||||
|
|
||||||
if (Testsuite::handleInteractiveInput(info, "OK", "Skip", kOptionRight)) {
|
|
||||||
Testsuite::logPrintf("Info! Skipping test : testOtherConversions\n");
|
|
||||||
return kTestSkipped;
|
|
||||||
}
|
|
||||||
unsigned char cp850[] = {0x99, 0xE0, 0xEA, 0x41, 0x64, 0};
|
|
||||||
unsigned char utf8_1[] = {0xC3, 0x96, 0xC3, 0x93, 0xC3, 0x9B, 0x41, 0x64, 0};
|
|
||||||
|
|
||||||
unsigned char iso_8859_2[] = {0xA9, 0xE1, 0x6C, 0x65, 0xE8, 0x65, 0x6B, 0};
|
|
||||||
unsigned char utf8_2[] = {0xC5, 0xA0, 0xC3, 0xA1, 0x6C, 0x65, 0xC4, 0x8D, 0x65, 0x6B, 0};
|
|
||||||
|
|
||||||
char *result = Common::Encoding::convert("UTF-8", "CP850", (char *)cp850, 5);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("CP850 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8_1, 9)) {
|
|
||||||
Testsuite::logPrintf("CP850 to UTF-8 conversion isn'differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("CP850", "UTF-8", (char *)utf8_1, 8);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to CP850 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, cp850, 6)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to CP850 conversion isn'differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("UTF-8", "iso-8859-2", (char *)iso_8859_2, 7);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("iso-8859-2 to UTF-8 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, utf8_2, 11)) {
|
|
||||||
Testsuite::logPrintf("iso-8859-2 to UTF-differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
|
|
||||||
result = Common::Encoding::convert("iso-8859-2", "UTF-8", (char *)utf8_2, 11);
|
|
||||||
if (result == NULL) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to iso-8859-2 conversion isn't available");
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
if (memcmp(result, iso_8859_2, 8)) {
|
|
||||||
Testsuite::logPrintf("UTF-8 to iso-8859-differs from the expected result.");
|
|
||||||
free(result);
|
|
||||||
return kTestFailed;
|
|
||||||
}
|
|
||||||
free(result);
|
|
||||||
return kTestPassed;
|
|
||||||
}
|
|
||||||
|
|
||||||
EncodingTestSuite::EncodingTestSuite() {
|
|
||||||
addTest("testConversionUnicodeMachineEndian", &Encodingtests::testConversionUnicodeMachineEndian, true);
|
|
||||||
addTest("testConversionUnicodeBigEndian", &Encodingtests::testConversionUnicodeBigEndian, true);
|
|
||||||
addTest("testConversionUnicodeLittleEndian", &Encodingtests::testConversionUnicodeLittleEndian, true);
|
|
||||||
addTest("testCyrillicTransliteration", &Encodingtests::testCyrillicTransliteration, true);
|
|
||||||
addTest("testOtherConversions", &Encodingtests::testOtherConversions, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // End of namespace Testbed
|
|
|
@ -1,71 +0,0 @@
|
||||||
/* ScummVM - Graphic Adventure Engine
|
|
||||||
*
|
|
||||||
* ScummVM is the legal property of its developers, whose names
|
|
||||||
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
||||||
* file distributed with this source distribution.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef TESTBED_ENCODING_H
|
|
||||||
#define TESTBED_ENCODING_H
|
|
||||||
|
|
||||||
#include "testbed/testsuite.h"
|
|
||||||
#include "common/encoding.h"
|
|
||||||
|
|
||||||
namespace Testbed {
|
|
||||||
|
|
||||||
namespace Encodingtests {
|
|
||||||
|
|
||||||
// Helper functions for Encoding tests
|
|
||||||
|
|
||||||
// will contain function declarations for Encoding tests
|
|
||||||
// add more here
|
|
||||||
|
|
||||||
TestExitStatus testConversionUnicodeMachineEndian();
|
|
||||||
TestExitStatus testConversionUnicodeBigEndian();
|
|
||||||
TestExitStatus testConversionUnicodeLittleEndian();
|
|
||||||
TestExitStatus testCyrillicTransliteration();
|
|
||||||
TestExitStatus testOtherConversions();
|
|
||||||
|
|
||||||
} // End of namespace Encodingtests
|
|
||||||
|
|
||||||
class EncodingTestSuite : public Testsuite {
|
|
||||||
public:
|
|
||||||
/**
|
|
||||||
* The constructor for the XXXTestSuite
|
|
||||||
* For every test to be executed one must:
|
|
||||||
* 1) Create a function that would invoke the test
|
|
||||||
* 2) Add that test to list by executing addTest()
|
|
||||||
*
|
|
||||||
* @see addTest()
|
|
||||||
*/
|
|
||||||
EncodingTestSuite();
|
|
||||||
~EncodingTestSuite() override {}
|
|
||||||
const char *getName() const override {
|
|
||||||
return "Encoding";
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *getDescription() const override {
|
|
||||||
return "Encoding conversion";
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
} // End of namespace Testbed
|
|
||||||
|
|
||||||
#endif // TESTBED_ENCODING_H
|
|
|
@ -12,7 +12,6 @@ MODULE_OBJS := \
|
||||||
networking.o \
|
networking.o \
|
||||||
savegame.o \
|
savegame.o \
|
||||||
sound.o \
|
sound.o \
|
||||||
encoding.o \
|
|
||||||
testbed.o \
|
testbed.o \
|
||||||
testsuite.o \
|
testsuite.o \
|
||||||
video.o
|
video.o
|
||||||
|
|
|
@ -40,7 +40,6 @@
|
||||||
#include "testbed/networking.h"
|
#include "testbed/networking.h"
|
||||||
#include "testbed/savegame.h"
|
#include "testbed/savegame.h"
|
||||||
#include "testbed/sound.h"
|
#include "testbed/sound.h"
|
||||||
#include "testbed/encoding.h"
|
|
||||||
#include "testbed/testbed.h"
|
#include "testbed/testbed.h"
|
||||||
#ifdef USE_CLOUD
|
#ifdef USE_CLOUD
|
||||||
#include "testbed/cloud.h"
|
#include "testbed/cloud.h"
|
||||||
|
@ -169,8 +168,6 @@ void TestbedEngine::pushTestsuites(Common::Array<Testsuite *> &testsuiteList) {
|
||||||
ts = new WebserverTestSuite();
|
ts = new WebserverTestSuite();
|
||||||
testsuiteList.push_back(ts);
|
testsuiteList.push_back(ts);
|
||||||
#endif
|
#endif
|
||||||
ts = new EncodingTestSuite();
|
|
||||||
testsuiteList.push_back(ts);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TestbedEngine::~TestbedEngine() {
|
TestbedEngine::~TestbedEngine() {
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
#include "graphics/font.h"
|
#include "graphics/font.h"
|
||||||
#include "graphics/surface.h"
|
#include "graphics/surface.h"
|
||||||
|
|
||||||
#include "common/encoding.h"
|
#include "common/ustr.h"
|
||||||
#include "common/file.h"
|
#include "common/file.h"
|
||||||
#include "common/config-manager.h"
|
#include "common/config-manager.h"
|
||||||
#include "common/singleton.h"
|
#include "common/singleton.h"
|
||||||
|
@ -883,9 +883,7 @@ static bool matchFaceName(const Common::U32String &faceName, const FT_Face &face
|
||||||
if (aname.encoding_id == TT_MS_ID_SYMBOL_CS ||
|
if (aname.encoding_id == TT_MS_ID_SYMBOL_CS ||
|
||||||
aname.encoding_id == TT_MS_ID_UNICODE_CS) {
|
aname.encoding_id == TT_MS_ID_UNICODE_CS) {
|
||||||
// MS local name in UTF-16
|
// MS local name in UTF-16
|
||||||
char *u32 = Common::Encoding::convert("utf-32", "utf-16be", (char *)aname.string, aname.string_len);
|
Common::U32String localName = Common::U32String::decodeUTF16BE((uint16 *) aname.string, aname.string_len);
|
||||||
Common::U32String localName((uint32 *)u32);
|
|
||||||
free(u32);
|
|
||||||
|
|
||||||
if (faceName == localName) {
|
if (faceName == localName) {
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -39,164 +39,9 @@ bool checkKorCode(byte hi, byte lo) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// KS (EUC-KR) to UCS-2 table
|
|
||||||
static const uint16 _ksToUcs2Table[2350] = {
|
|
||||||
0xac00, 0xac01, 0xac04, 0xac07, 0xac08, 0xac09, 0xac0a, 0xac10, 0xac11, 0xac12, 0xac13, 0xac14, 0xac15, 0xac16, 0xac17, 0xac19,
|
|
||||||
0xac1a, 0xac1b, 0xac1c, 0xac1d, 0xac20, 0xac24, 0xac2c, 0xac2d, 0xac2f, 0xac30, 0xac31, 0xac38, 0xac39, 0xac3c, 0xac40, 0xac4b,
|
|
||||||
0xac4d, 0xac54, 0xac58, 0xac5c, 0xac70, 0xac71, 0xac74, 0xac77, 0xac78, 0xac7a, 0xac80, 0xac81, 0xac83, 0xac84, 0xac85, 0xac86,
|
|
||||||
0xac89, 0xac8a, 0xac8b, 0xac8c, 0xac90, 0xac94, 0xac9c, 0xac9d, 0xac9f, 0xaca0, 0xaca1, 0xaca8, 0xaca9, 0xacaa, 0xacac, 0xacaf,
|
|
||||||
0xacb0, 0xacb8, 0xacb9, 0xacbb, 0xacbc, 0xacbd, 0xacc1, 0xacc4, 0xacc8, 0xaccc, 0xacd5, 0xacd7, 0xace0, 0xace1, 0xace4, 0xace7,
|
|
||||||
0xace8, 0xacea, 0xacec, 0xacef, 0xacf0, 0xacf1, 0xacf3, 0xacf5, 0xacf6, 0xacfc, 0xacfd, 0xad00, 0xad04, 0xad06, 0xad0c, 0xad0d,
|
|
||||||
0xad0f, 0xad11, 0xad18, 0xad1c, 0xad20, 0xad28, 0xad2c, 0xad2d, 0xad34, 0xad35, 0xad38, 0xad3c, 0xad44, 0xad45, 0xad47, 0xad49,
|
|
||||||
0xad50, 0xad54, 0xad58, 0xad61, 0xad63, 0xad6c, 0xad6d, 0xad70, 0xad73, 0xad74, 0xad75, 0xad76, 0xad7b, 0xad7c, 0xad7d, 0xad7f,
|
|
||||||
0xad81, 0xad82, 0xad88, 0xad89, 0xad8c, 0xad90, 0xad9c, 0xad9d, 0xada4, 0xadb7, 0xadc0, 0xadc1, 0xadc4, 0xadc8, 0xadd0, 0xadd1,
|
|
||||||
0xadd3, 0xaddc, 0xade0, 0xade4, 0xadf8, 0xadf9, 0xadfc, 0xadff, 0xae00, 0xae01, 0xae08, 0xae09, 0xae0b, 0xae0d, 0xae14, 0xae30,
|
|
||||||
0xae31, 0xae34, 0xae37, 0xae38, 0xae3a, 0xae40, 0xae41, 0xae43, 0xae45, 0xae46, 0xae4a, 0xae4c, 0xae4d, 0xae4e, 0xae50, 0xae54,
|
|
||||||
0xae56, 0xae5c, 0xae5d, 0xae5f, 0xae60, 0xae61, 0xae65, 0xae68, 0xae69, 0xae6c, 0xae70, 0xae78, 0xae79, 0xae7b, 0xae7c, 0xae7d,
|
|
||||||
0xae84, 0xae85, 0xae8c, 0xaebc, 0xaebd, 0xaebe, 0xaec0, 0xaec4, 0xaecc, 0xaecd, 0xaecf, 0xaed0, 0xaed1, 0xaed8, 0xaed9, 0xaedc,
|
|
||||||
0xaee8, 0xaeeb, 0xaeed, 0xaef4, 0xaef8, 0xaefc, 0xaf07, 0xaf08, 0xaf0d, 0xaf10, 0xaf2c, 0xaf2d, 0xaf30, 0xaf32, 0xaf34, 0xaf3c,
|
|
||||||
0xaf3d, 0xaf3f, 0xaf41, 0xaf42, 0xaf43, 0xaf48, 0xaf49, 0xaf50, 0xaf5c, 0xaf5d, 0xaf64, 0xaf65, 0xaf79, 0xaf80, 0xaf84, 0xaf88,
|
|
||||||
0xaf90, 0xaf91, 0xaf95, 0xaf9c, 0xafb8, 0xafb9, 0xafbc, 0xafc0, 0xafc7, 0xafc8, 0xafc9, 0xafcb, 0xafcd, 0xafce, 0xafd4, 0xafdc,
|
|
||||||
0xafe8, 0xafe9, 0xaff0, 0xaff1, 0xaff4, 0xaff8, 0xb000, 0xb001, 0xb004, 0xb00c, 0xb010, 0xb014, 0xb01c, 0xb01d, 0xb028, 0xb044,
|
|
||||||
0xb045, 0xb048, 0xb04a, 0xb04c, 0xb04e, 0xb053, 0xb054, 0xb055, 0xb057, 0xb059, 0xb05d, 0xb07c, 0xb07d, 0xb080, 0xb084, 0xb08c,
|
|
||||||
0xb08d, 0xb08f, 0xb091, 0xb098, 0xb099, 0xb09a, 0xb09c, 0xb09f, 0xb0a0, 0xb0a1, 0xb0a2, 0xb0a8, 0xb0a9, 0xb0ab, 0xb0ac, 0xb0ad,
|
|
||||||
0xb0ae, 0xb0af, 0xb0b1, 0xb0b3, 0xb0b4, 0xb0b5, 0xb0b8, 0xb0bc, 0xb0c4, 0xb0c5, 0xb0c7, 0xb0c8, 0xb0c9, 0xb0d0, 0xb0d1, 0xb0d4,
|
|
||||||
0xb0d8, 0xb0e0, 0xb0e5, 0xb108, 0xb109, 0xb10b, 0xb10c, 0xb110, 0xb112, 0xb113, 0xb118, 0xb119, 0xb11b, 0xb11c, 0xb11d, 0xb123,
|
|
||||||
0xb124, 0xb125, 0xb128, 0xb12c, 0xb134, 0xb135, 0xb137, 0xb138, 0xb139, 0xb140, 0xb141, 0xb144, 0xb148, 0xb150, 0xb151, 0xb154,
|
|
||||||
0xb155, 0xb158, 0xb15c, 0xb160, 0xb178, 0xb179, 0xb17c, 0xb180, 0xb182, 0xb188, 0xb189, 0xb18b, 0xb18d, 0xb192, 0xb193, 0xb194,
|
|
||||||
0xb198, 0xb19c, 0xb1a8, 0xb1cc, 0xb1d0, 0xb1d4, 0xb1dc, 0xb1dd, 0xb1df, 0xb1e8, 0xb1e9, 0xb1ec, 0xb1f0, 0xb1f9, 0xb1fb, 0xb1fd,
|
|
||||||
0xb204, 0xb205, 0xb208, 0xb20b, 0xb20c, 0xb214, 0xb215, 0xb217, 0xb219, 0xb220, 0xb234, 0xb23c, 0xb258, 0xb25c, 0xb260, 0xb268,
|
|
||||||
0xb269, 0xb274, 0xb275, 0xb27c, 0xb284, 0xb285, 0xb289, 0xb290, 0xb291, 0xb294, 0xb298, 0xb299, 0xb29a, 0xb2a0, 0xb2a1, 0xb2a3,
|
|
||||||
0xb2a5, 0xb2a6, 0xb2aa, 0xb2ac, 0xb2b0, 0xb2b4, 0xb2c8, 0xb2c9, 0xb2cc, 0xb2d0, 0xb2d6, 0xb2d8, 0xb2d9, 0xb2db, 0xb2dd, 0xb2e2,
|
|
||||||
0xb2e4, 0xb2e5, 0xb2e6, 0xb2e8, 0xb2eb, 0xb2ec, 0xb2ed, 0xb2ee, 0xb2ef, 0xb2f3, 0xb2f4, 0xb2f5, 0xb2f7, 0xb2f8, 0xb2f9, 0xb2fa,
|
|
||||||
0xb2fb, 0xb2ff, 0xb300, 0xb301, 0xb304, 0xb308, 0xb310, 0xb311, 0xb313, 0xb314, 0xb315, 0xb31c, 0xb354, 0xb355, 0xb356, 0xb358,
|
|
||||||
0xb35b, 0xb35c, 0xb35e, 0xb35f, 0xb364, 0xb365, 0xb367, 0xb369, 0xb36b, 0xb36e, 0xb370, 0xb371, 0xb374, 0xb378, 0xb380, 0xb381,
|
|
||||||
0xb383, 0xb384, 0xb385, 0xb38c, 0xb390, 0xb394, 0xb3a0, 0xb3a1, 0xb3a8, 0xb3ac, 0xb3c4, 0xb3c5, 0xb3c8, 0xb3cb, 0xb3cc, 0xb3ce,
|
|
||||||
0xb3d0, 0xb3d4, 0xb3d5, 0xb3d7, 0xb3d9, 0xb3db, 0xb3dd, 0xb3e0, 0xb3e4, 0xb3e8, 0xb3fc, 0xb410, 0xb418, 0xb41c, 0xb420, 0xb428,
|
|
||||||
0xb429, 0xb42b, 0xb434, 0xb450, 0xb451, 0xb454, 0xb458, 0xb460, 0xb461, 0xb463, 0xb465, 0xb46c, 0xb480, 0xb488, 0xb49d, 0xb4a4,
|
|
||||||
0xb4a8, 0xb4ac, 0xb4b5, 0xb4b7, 0xb4b9, 0xb4c0, 0xb4c4, 0xb4c8, 0xb4d0, 0xb4d5, 0xb4dc, 0xb4dd, 0xb4e0, 0xb4e3, 0xb4e4, 0xb4e6,
|
|
||||||
0xb4ec, 0xb4ed, 0xb4ef, 0xb4f1, 0xb4f8, 0xb514, 0xb515, 0xb518, 0xb51b, 0xb51c, 0xb524, 0xb525, 0xb527, 0xb528, 0xb529, 0xb52a,
|
|
||||||
0xb530, 0xb531, 0xb534, 0xb538, 0xb540, 0xb541, 0xb543, 0xb544, 0xb545, 0xb54b, 0xb54c, 0xb54d, 0xb550, 0xb554, 0xb55c, 0xb55d,
|
|
||||||
0xb55f, 0xb560, 0xb561, 0xb5a0, 0xb5a1, 0xb5a4, 0xb5a8, 0xb5aa, 0xb5ab, 0xb5b0, 0xb5b1, 0xb5b3, 0xb5b4, 0xb5b5, 0xb5bb, 0xb5bc,
|
|
||||||
0xb5bd, 0xb5c0, 0xb5c4, 0xb5cc, 0xb5cd, 0xb5cf, 0xb5d0, 0xb5d1, 0xb5d8, 0xb5ec, 0xb610, 0xb611, 0xb614, 0xb618, 0xb625, 0xb62c,
|
|
||||||
0xb634, 0xb648, 0xb664, 0xb668, 0xb69c, 0xb69d, 0xb6a0, 0xb6a4, 0xb6ab, 0xb6ac, 0xb6b1, 0xb6d4, 0xb6f0, 0xb6f4, 0xb6f8, 0xb700,
|
|
||||||
0xb701, 0xb705, 0xb728, 0xb729, 0xb72c, 0xb72f, 0xb730, 0xb738, 0xb739, 0xb73b, 0xb744, 0xb748, 0xb74c, 0xb754, 0xb755, 0xb760,
|
|
||||||
0xb764, 0xb768, 0xb770, 0xb771, 0xb773, 0xb775, 0xb77c, 0xb77d, 0xb780, 0xb784, 0xb78c, 0xb78d, 0xb78f, 0xb790, 0xb791, 0xb792,
|
|
||||||
0xb796, 0xb797, 0xb798, 0xb799, 0xb79c, 0xb7a0, 0xb7a8, 0xb7a9, 0xb7ab, 0xb7ac, 0xb7ad, 0xb7b4, 0xb7b5, 0xb7b8, 0xb7c7, 0xb7c9,
|
|
||||||
0xb7ec, 0xb7ed, 0xb7f0, 0xb7f4, 0xb7fc, 0xb7fd, 0xb7ff, 0xb800, 0xb801, 0xb807, 0xb808, 0xb809, 0xb80c, 0xb810, 0xb818, 0xb819,
|
|
||||||
0xb81b, 0xb81d, 0xb824, 0xb825, 0xb828, 0xb82c, 0xb834, 0xb835, 0xb837, 0xb838, 0xb839, 0xb840, 0xb844, 0xb851, 0xb853, 0xb85c,
|
|
||||||
0xb85d, 0xb860, 0xb864, 0xb86c, 0xb86d, 0xb86f, 0xb871, 0xb878, 0xb87c, 0xb88d, 0xb8a8, 0xb8b0, 0xb8b4, 0xb8b8, 0xb8c0, 0xb8c1,
|
|
||||||
0xb8c3, 0xb8c5, 0xb8cc, 0xb8d0, 0xb8d4, 0xb8dd, 0xb8df, 0xb8e1, 0xb8e8, 0xb8e9, 0xb8ec, 0xb8f0, 0xb8f8, 0xb8f9, 0xb8fb, 0xb8fd,
|
|
||||||
0xb904, 0xb918, 0xb920, 0xb93c, 0xb93d, 0xb940, 0xb944, 0xb94c, 0xb94f, 0xb951, 0xb958, 0xb959, 0xb95c, 0xb960, 0xb968, 0xb969,
|
|
||||||
0xb96b, 0xb96d, 0xb974, 0xb975, 0xb978, 0xb97c, 0xb984, 0xb985, 0xb987, 0xb989, 0xb98a, 0xb98d, 0xb98e, 0xb9ac, 0xb9ad, 0xb9b0,
|
|
||||||
0xb9b4, 0xb9bc, 0xb9bd, 0xb9bf, 0xb9c1, 0xb9c8, 0xb9c9, 0xb9cc, 0xb9ce, 0xb9cf, 0xb9d0, 0xb9d1, 0xb9d2, 0xb9d8, 0xb9d9, 0xb9db,
|
|
||||||
0xb9dd, 0xb9de, 0xb9e1, 0xb9e3, 0xb9e4, 0xb9e5, 0xb9e8, 0xb9ec, 0xb9f4, 0xb9f5, 0xb9f7, 0xb9f8, 0xb9f9, 0xb9fa, 0xba00, 0xba01,
|
|
||||||
0xba08, 0xba15, 0xba38, 0xba39, 0xba3c, 0xba40, 0xba42, 0xba48, 0xba49, 0xba4b, 0xba4d, 0xba4e, 0xba53, 0xba54, 0xba55, 0xba58,
|
|
||||||
0xba5c, 0xba64, 0xba65, 0xba67, 0xba68, 0xba69, 0xba70, 0xba71, 0xba74, 0xba78, 0xba83, 0xba84, 0xba85, 0xba87, 0xba8c, 0xbaa8,
|
|
||||||
0xbaa9, 0xbaab, 0xbaac, 0xbab0, 0xbab2, 0xbab8, 0xbab9, 0xbabb, 0xbabd, 0xbac4, 0xbac8, 0xbad8, 0xbad9, 0xbafc, 0xbb00, 0xbb04,
|
|
||||||
0xbb0d, 0xbb0f, 0xbb11, 0xbb18, 0xbb1c, 0xbb20, 0xbb29, 0xbb2b, 0xbb34, 0xbb35, 0xbb36, 0xbb38, 0xbb3b, 0xbb3c, 0xbb3d, 0xbb3e,
|
|
||||||
0xbb44, 0xbb45, 0xbb47, 0xbb49, 0xbb4d, 0xbb4f, 0xbb50, 0xbb54, 0xbb58, 0xbb61, 0xbb63, 0xbb6c, 0xbb88, 0xbb8c, 0xbb90, 0xbba4,
|
|
||||||
0xbba8, 0xbbac, 0xbbb4, 0xbbb7, 0xbbc0, 0xbbc4, 0xbbc8, 0xbbd0, 0xbbd3, 0xbbf8, 0xbbf9, 0xbbfc, 0xbbff, 0xbc00, 0xbc02, 0xbc08,
|
|
||||||
0xbc09, 0xbc0b, 0xbc0c, 0xbc0d, 0xbc0f, 0xbc11, 0xbc14, 0xbc15, 0xbc16, 0xbc17, 0xbc18, 0xbc1b, 0xbc1c, 0xbc1d, 0xbc1e, 0xbc1f,
|
|
||||||
0xbc24, 0xbc25, 0xbc27, 0xbc29, 0xbc2d, 0xbc30, 0xbc31, 0xbc34, 0xbc38, 0xbc40, 0xbc41, 0xbc43, 0xbc44, 0xbc45, 0xbc49, 0xbc4c,
|
|
||||||
0xbc4d, 0xbc50, 0xbc5d, 0xbc84, 0xbc85, 0xbc88, 0xbc8b, 0xbc8c, 0xbc8e, 0xbc94, 0xbc95, 0xbc97, 0xbc99, 0xbc9a, 0xbca0, 0xbca1,
|
|
||||||
0xbca4, 0xbca7, 0xbca8, 0xbcb0, 0xbcb1, 0xbcb3, 0xbcb4, 0xbcb5, 0xbcbc, 0xbcbd, 0xbcc0, 0xbcc4, 0xbccd, 0xbccf, 0xbcd0, 0xbcd1,
|
|
||||||
0xbcd5, 0xbcd8, 0xbcdc, 0xbcf4, 0xbcf5, 0xbcf6, 0xbcf8, 0xbcfc, 0xbd04, 0xbd05, 0xbd07, 0xbd09, 0xbd10, 0xbd14, 0xbd24, 0xbd2c,
|
|
||||||
0xbd40, 0xbd48, 0xbd49, 0xbd4c, 0xbd50, 0xbd58, 0xbd59, 0xbd64, 0xbd68, 0xbd80, 0xbd81, 0xbd84, 0xbd87, 0xbd88, 0xbd89, 0xbd8a,
|
|
||||||
0xbd90, 0xbd91, 0xbd93, 0xbd95, 0xbd99, 0xbd9a, 0xbd9c, 0xbda4, 0xbdb0, 0xbdb8, 0xbdd4, 0xbdd5, 0xbdd8, 0xbddc, 0xbde9, 0xbdf0,
|
|
||||||
0xbdf4, 0xbdf8, 0xbe00, 0xbe03, 0xbe05, 0xbe0c, 0xbe0d, 0xbe10, 0xbe14, 0xbe1c, 0xbe1d, 0xbe1f, 0xbe44, 0xbe45, 0xbe48, 0xbe4c,
|
|
||||||
0xbe4e, 0xbe54, 0xbe55, 0xbe57, 0xbe59, 0xbe5a, 0xbe5b, 0xbe60, 0xbe61, 0xbe64, 0xbe68, 0xbe6a, 0xbe70, 0xbe71, 0xbe73, 0xbe74,
|
|
||||||
0xbe75, 0xbe7b, 0xbe7c, 0xbe7d, 0xbe80, 0xbe84, 0xbe8c, 0xbe8d, 0xbe8f, 0xbe90, 0xbe91, 0xbe98, 0xbe99, 0xbea8, 0xbed0, 0xbed1,
|
|
||||||
0xbed4, 0xbed7, 0xbed8, 0xbee0, 0xbee3, 0xbee4, 0xbee5, 0xbeec, 0xbf01, 0xbf08, 0xbf09, 0xbf18, 0xbf19, 0xbf1b, 0xbf1c, 0xbf1d,
|
|
||||||
0xbf40, 0xbf41, 0xbf44, 0xbf48, 0xbf50, 0xbf51, 0xbf55, 0xbf94, 0xbfb0, 0xbfc5, 0xbfcc, 0xbfcd, 0xbfd0, 0xbfd4, 0xbfdc, 0xbfdf,
|
|
||||||
0xbfe1, 0xc03c, 0xc051, 0xc058, 0xc05c, 0xc060, 0xc068, 0xc069, 0xc090, 0xc091, 0xc094, 0xc098, 0xc0a0, 0xc0a1, 0xc0a3, 0xc0a5,
|
|
||||||
0xc0ac, 0xc0ad, 0xc0af, 0xc0b0, 0xc0b3, 0xc0b4, 0xc0b5, 0xc0b6, 0xc0bc, 0xc0bd, 0xc0bf, 0xc0c0, 0xc0c1, 0xc0c5, 0xc0c8, 0xc0c9,
|
|
||||||
0xc0cc, 0xc0d0, 0xc0d8, 0xc0d9, 0xc0db, 0xc0dc, 0xc0dd, 0xc0e4, 0xc0e5, 0xc0e8, 0xc0ec, 0xc0f4, 0xc0f5, 0xc0f7, 0xc0f9, 0xc100,
|
|
||||||
0xc104, 0xc108, 0xc110, 0xc115, 0xc11c, 0xc11d, 0xc11e, 0xc11f, 0xc120, 0xc123, 0xc124, 0xc126, 0xc127, 0xc12c, 0xc12d, 0xc12f,
|
|
||||||
0xc130, 0xc131, 0xc136, 0xc138, 0xc139, 0xc13c, 0xc140, 0xc148, 0xc149, 0xc14b, 0xc14c, 0xc14d, 0xc154, 0xc155, 0xc158, 0xc15c,
|
|
||||||
0xc164, 0xc165, 0xc167, 0xc168, 0xc169, 0xc170, 0xc174, 0xc178, 0xc185, 0xc18c, 0xc18d, 0xc18e, 0xc190, 0xc194, 0xc196, 0xc19c,
|
|
||||||
0xc19d, 0xc19f, 0xc1a1, 0xc1a5, 0xc1a8, 0xc1a9, 0xc1ac, 0xc1b0, 0xc1bd, 0xc1c4, 0xc1c8, 0xc1cc, 0xc1d4, 0xc1d7, 0xc1d8, 0xc1e0,
|
|
||||||
0xc1e4, 0xc1e8, 0xc1f0, 0xc1f1, 0xc1f3, 0xc1fc, 0xc1fd, 0xc200, 0xc204, 0xc20c, 0xc20d, 0xc20f, 0xc211, 0xc218, 0xc219, 0xc21c,
|
|
||||||
0xc21f, 0xc220, 0xc228, 0xc229, 0xc22b, 0xc22d, 0xc22f, 0xc231, 0xc232, 0xc234, 0xc248, 0xc250, 0xc251, 0xc254, 0xc258, 0xc260,
|
|
||||||
0xc265, 0xc26c, 0xc26d, 0xc270, 0xc274, 0xc27c, 0xc27d, 0xc27f, 0xc281, 0xc288, 0xc289, 0xc290, 0xc298, 0xc29b, 0xc29d, 0xc2a4,
|
|
||||||
0xc2a5, 0xc2a8, 0xc2ac, 0xc2ad, 0xc2b4, 0xc2b5, 0xc2b7, 0xc2b9, 0xc2dc, 0xc2dd, 0xc2e0, 0xc2e3, 0xc2e4, 0xc2eb, 0xc2ec, 0xc2ed,
|
|
||||||
0xc2ef, 0xc2f1, 0xc2f6, 0xc2f8, 0xc2f9, 0xc2fb, 0xc2fc, 0xc300, 0xc308, 0xc309, 0xc30c, 0xc30d, 0xc313, 0xc314, 0xc315, 0xc318,
|
|
||||||
0xc31c, 0xc324, 0xc325, 0xc328, 0xc329, 0xc345, 0xc368, 0xc369, 0xc36c, 0xc370, 0xc372, 0xc378, 0xc379, 0xc37c, 0xc37d, 0xc384,
|
|
||||||
0xc388, 0xc38c, 0xc399, 0xc3d8, 0xc3d9, 0xc3dc, 0xc3df, 0xc3e0, 0xc3e2, 0xc3e8, 0xc3e9, 0xc3ed, 0xc3f4, 0xc3f5, 0xc3f8, 0xc408,
|
|
||||||
0xc410, 0xc424, 0xc42c, 0xc430, 0xc434, 0xc43c, 0xc43d, 0xc448, 0xc464, 0xc465, 0xc468, 0xc46c, 0xc474, 0xc475, 0xc479, 0xc480,
|
|
||||||
0xc494, 0xc49c, 0xc4b8, 0xc4bc, 0xc4e9, 0xc4f0, 0xc4f1, 0xc4f4, 0xc4f8, 0xc4fa, 0xc4ff, 0xc500, 0xc501, 0xc50c, 0xc510, 0xc514,
|
|
||||||
0xc51c, 0xc528, 0xc529, 0xc52c, 0xc530, 0xc538, 0xc539, 0xc53b, 0xc53d, 0xc544, 0xc545, 0xc548, 0xc549, 0xc54a, 0xc54c, 0xc54d,
|
|
||||||
0xc54e, 0xc553, 0xc554, 0xc555, 0xc557, 0xc558, 0xc559, 0xc55d, 0xc55e, 0xc560, 0xc561, 0xc564, 0xc568, 0xc570, 0xc571, 0xc573,
|
|
||||||
0xc574, 0xc575, 0xc57c, 0xc57d, 0xc580, 0xc584, 0xc587, 0xc58c, 0xc58d, 0xc58f, 0xc591, 0xc595, 0xc597, 0xc598, 0xc59c, 0xc5a0,
|
|
||||||
0xc5a9, 0xc5b4, 0xc5b5, 0xc5b8, 0xc5b9, 0xc5bb, 0xc5bc, 0xc5bd, 0xc5be, 0xc5c4, 0xc5c5, 0xc5c6, 0xc5c7, 0xc5c8, 0xc5c9, 0xc5ca,
|
|
||||||
0xc5cc, 0xc5ce, 0xc5d0, 0xc5d1, 0xc5d4, 0xc5d8, 0xc5e0, 0xc5e1, 0xc5e3, 0xc5e5, 0xc5ec, 0xc5ed, 0xc5ee, 0xc5f0, 0xc5f4, 0xc5f6,
|
|
||||||
0xc5f7, 0xc5fc, 0xc5fd, 0xc5fe, 0xc5ff, 0xc600, 0xc601, 0xc605, 0xc606, 0xc607, 0xc608, 0xc60c, 0xc610, 0xc618, 0xc619, 0xc61b,
|
|
||||||
0xc61c, 0xc624, 0xc625, 0xc628, 0xc62c, 0xc62d, 0xc62e, 0xc630, 0xc633, 0xc634, 0xc635, 0xc637, 0xc639, 0xc63b, 0xc640, 0xc641,
|
|
||||||
0xc644, 0xc648, 0xc650, 0xc651, 0xc653, 0xc654, 0xc655, 0xc65c, 0xc65d, 0xc660, 0xc66c, 0xc66f, 0xc671, 0xc678, 0xc679, 0xc67c,
|
|
||||||
0xc680, 0xc688, 0xc689, 0xc68b, 0xc68d, 0xc694, 0xc695, 0xc698, 0xc69c, 0xc6a4, 0xc6a5, 0xc6a7, 0xc6a9, 0xc6b0, 0xc6b1, 0xc6b4,
|
|
||||||
0xc6b8, 0xc6b9, 0xc6ba, 0xc6c0, 0xc6c1, 0xc6c3, 0xc6c5, 0xc6cc, 0xc6cd, 0xc6d0, 0xc6d4, 0xc6dc, 0xc6dd, 0xc6e0, 0xc6e1, 0xc6e8,
|
|
||||||
0xc6e9, 0xc6ec, 0xc6f0, 0xc6f8, 0xc6f9, 0xc6fd, 0xc704, 0xc705, 0xc708, 0xc70c, 0xc714, 0xc715, 0xc717, 0xc719, 0xc720, 0xc721,
|
|
||||||
0xc724, 0xc728, 0xc730, 0xc731, 0xc733, 0xc735, 0xc737, 0xc73c, 0xc73d, 0xc740, 0xc744, 0xc74a, 0xc74c, 0xc74d, 0xc74f, 0xc751,
|
|
||||||
0xc752, 0xc753, 0xc754, 0xc755, 0xc756, 0xc757, 0xc758, 0xc75c, 0xc760, 0xc768, 0xc76b, 0xc774, 0xc775, 0xc778, 0xc77c, 0xc77d,
|
|
||||||
0xc77e, 0xc783, 0xc784, 0xc785, 0xc787, 0xc788, 0xc789, 0xc78a, 0xc78e, 0xc790, 0xc791, 0xc794, 0xc796, 0xc797, 0xc798, 0xc79a,
|
|
||||||
0xc7a0, 0xc7a1, 0xc7a3, 0xc7a4, 0xc7a5, 0xc7a6, 0xc7ac, 0xc7ad, 0xc7b0, 0xc7b4, 0xc7bc, 0xc7bd, 0xc7bf, 0xc7c0, 0xc7c1, 0xc7c8,
|
|
||||||
0xc7c9, 0xc7cc, 0xc7ce, 0xc7d0, 0xc7d8, 0xc7dd, 0xc7e4, 0xc7e8, 0xc7ec, 0xc800, 0xc801, 0xc804, 0xc808, 0xc80a, 0xc810, 0xc811,
|
|
||||||
0xc813, 0xc815, 0xc816, 0xc81c, 0xc81d, 0xc820, 0xc824, 0xc82c, 0xc82d, 0xc82f, 0xc831, 0xc838, 0xc83c, 0xc840, 0xc848, 0xc849,
|
|
||||||
0xc84c, 0xc84d, 0xc854, 0xc870, 0xc871, 0xc874, 0xc878, 0xc87a, 0xc880, 0xc881, 0xc883, 0xc885, 0xc886, 0xc887, 0xc88b, 0xc88c,
|
|
||||||
0xc88d, 0xc894, 0xc89d, 0xc89f, 0xc8a1, 0xc8a8, 0xc8bc, 0xc8bd, 0xc8c4, 0xc8c8, 0xc8cc, 0xc8d4, 0xc8d5, 0xc8d7, 0xc8d9, 0xc8e0,
|
|
||||||
0xc8e1, 0xc8e4, 0xc8f5, 0xc8fc, 0xc8fd, 0xc900, 0xc904, 0xc905, 0xc906, 0xc90c, 0xc90d, 0xc90f, 0xc911, 0xc918, 0xc92c, 0xc934,
|
|
||||||
0xc950, 0xc951, 0xc954, 0xc958, 0xc960, 0xc961, 0xc963, 0xc96c, 0xc970, 0xc974, 0xc97c, 0xc988, 0xc989, 0xc98c, 0xc990, 0xc998,
|
|
||||||
0xc999, 0xc99b, 0xc99d, 0xc9c0, 0xc9c1, 0xc9c4, 0xc9c7, 0xc9c8, 0xc9ca, 0xc9d0, 0xc9d1, 0xc9d3, 0xc9d5, 0xc9d6, 0xc9d9, 0xc9da,
|
|
||||||
0xc9dc, 0xc9dd, 0xc9e0, 0xc9e2, 0xc9e4, 0xc9e7, 0xc9ec, 0xc9ed, 0xc9ef, 0xc9f0, 0xc9f1, 0xc9f8, 0xc9f9, 0xc9fc, 0xca00, 0xca08,
|
|
||||||
0xca09, 0xca0b, 0xca0c, 0xca0d, 0xca14, 0xca18, 0xca29, 0xca4c, 0xca4d, 0xca50, 0xca54, 0xca5c, 0xca5d, 0xca5f, 0xca60, 0xca61,
|
|
||||||
0xca68, 0xca7d, 0xca84, 0xca98, 0xcabc, 0xcabd, 0xcac0, 0xcac4, 0xcacc, 0xcacd, 0xcacf, 0xcad1, 0xcad3, 0xcad8, 0xcad9, 0xcae0,
|
|
||||||
0xcaec, 0xcaf4, 0xcb08, 0xcb10, 0xcb14, 0xcb18, 0xcb20, 0xcb21, 0xcb41, 0xcb48, 0xcb49, 0xcb4c, 0xcb50, 0xcb58, 0xcb59, 0xcb5d,
|
|
||||||
0xcb64, 0xcb78, 0xcb79, 0xcb9c, 0xcbb8, 0xcbd4, 0xcbe4, 0xcbe7, 0xcbe9, 0xcc0c, 0xcc0d, 0xcc10, 0xcc14, 0xcc1c, 0xcc1d, 0xcc21,
|
|
||||||
0xcc22, 0xcc27, 0xcc28, 0xcc29, 0xcc2c, 0xcc2e, 0xcc30, 0xcc38, 0xcc39, 0xcc3b, 0xcc3c, 0xcc3d, 0xcc3e, 0xcc44, 0xcc45, 0xcc48,
|
|
||||||
0xcc4c, 0xcc54, 0xcc55, 0xcc57, 0xcc58, 0xcc59, 0xcc60, 0xcc64, 0xcc66, 0xcc68, 0xcc70, 0xcc75, 0xcc98, 0xcc99, 0xcc9c, 0xcca0,
|
|
||||||
0xcca8, 0xcca9, 0xccab, 0xccac, 0xccad, 0xccb4, 0xccb5, 0xccb8, 0xccbc, 0xccc4, 0xccc5, 0xccc7, 0xccc9, 0xccd0, 0xccd4, 0xcce4,
|
|
||||||
0xccec, 0xccf0, 0xcd01, 0xcd08, 0xcd09, 0xcd0c, 0xcd10, 0xcd18, 0xcd19, 0xcd1b, 0xcd1d, 0xcd24, 0xcd28, 0xcd2c, 0xcd39, 0xcd5c,
|
|
||||||
0xcd60, 0xcd64, 0xcd6c, 0xcd6d, 0xcd6f, 0xcd71, 0xcd78, 0xcd88, 0xcd94, 0xcd95, 0xcd98, 0xcd9c, 0xcda4, 0xcda5, 0xcda7, 0xcda9,
|
|
||||||
0xcdb0, 0xcdc4, 0xcdcc, 0xcdd0, 0xcde8, 0xcdec, 0xcdf0, 0xcdf8, 0xcdf9, 0xcdfb, 0xcdfd, 0xce04, 0xce08, 0xce0c, 0xce14, 0xce19,
|
|
||||||
0xce20, 0xce21, 0xce24, 0xce28, 0xce30, 0xce31, 0xce33, 0xce35, 0xce58, 0xce59, 0xce5c, 0xce5f, 0xce60, 0xce61, 0xce68, 0xce69,
|
|
||||||
0xce6b, 0xce6d, 0xce74, 0xce75, 0xce78, 0xce7c, 0xce84, 0xce85, 0xce87, 0xce89, 0xce90, 0xce91, 0xce94, 0xce98, 0xcea0, 0xcea1,
|
|
||||||
0xcea3, 0xcea4, 0xcea5, 0xceac, 0xcead, 0xcec1, 0xcee4, 0xcee5, 0xcee8, 0xceeb, 0xceec, 0xcef4, 0xcef5, 0xcef7, 0xcef8, 0xcef9,
|
|
||||||
0xcf00, 0xcf01, 0xcf04, 0xcf08, 0xcf10, 0xcf11, 0xcf13, 0xcf15, 0xcf1c, 0xcf20, 0xcf24, 0xcf2c, 0xcf2d, 0xcf2f, 0xcf30, 0xcf31,
|
|
||||||
0xcf38, 0xcf54, 0xcf55, 0xcf58, 0xcf5c, 0xcf64, 0xcf65, 0xcf67, 0xcf69, 0xcf70, 0xcf71, 0xcf74, 0xcf78, 0xcf80, 0xcf85, 0xcf8c,
|
|
||||||
0xcfa1, 0xcfa8, 0xcfb0, 0xcfc4, 0xcfe0, 0xcfe1, 0xcfe4, 0xcfe8, 0xcff0, 0xcff1, 0xcff3, 0xcff5, 0xcffc, 0xd000, 0xd004, 0xd011,
|
|
||||||
0xd018, 0xd02d, 0xd034, 0xd035, 0xd038, 0xd03c, 0xd044, 0xd045, 0xd047, 0xd049, 0xd050, 0xd054, 0xd058, 0xd060, 0xd06c, 0xd06d,
|
|
||||||
0xd070, 0xd074, 0xd07c, 0xd07d, 0xd081, 0xd0a4, 0xd0a5, 0xd0a8, 0xd0ac, 0xd0b4, 0xd0b5, 0xd0b7, 0xd0b9, 0xd0c0, 0xd0c1, 0xd0c4,
|
|
||||||
0xd0c8, 0xd0c9, 0xd0d0, 0xd0d1, 0xd0d3, 0xd0d4, 0xd0d5, 0xd0dc, 0xd0dd, 0xd0e0, 0xd0e4, 0xd0ec, 0xd0ed, 0xd0ef, 0xd0f0, 0xd0f1,
|
|
||||||
0xd0f8, 0xd10d, 0xd130, 0xd131, 0xd134, 0xd138, 0xd13a, 0xd140, 0xd141, 0xd143, 0xd144, 0xd145, 0xd14c, 0xd14d, 0xd150, 0xd154,
|
|
||||||
0xd15c, 0xd15d, 0xd15f, 0xd161, 0xd168, 0xd16c, 0xd17c, 0xd184, 0xd188, 0xd1a0, 0xd1a1, 0xd1a4, 0xd1a8, 0xd1b0, 0xd1b1, 0xd1b3,
|
|
||||||
0xd1b5, 0xd1ba, 0xd1bc, 0xd1c0, 0xd1d8, 0xd1f4, 0xd1f8, 0xd207, 0xd209, 0xd210, 0xd22c, 0xd22d, 0xd230, 0xd234, 0xd23c, 0xd23d,
|
|
||||||
0xd23f, 0xd241, 0xd248, 0xd25c, 0xd264, 0xd280, 0xd281, 0xd284, 0xd288, 0xd290, 0xd291, 0xd295, 0xd29c, 0xd2a0, 0xd2a4, 0xd2ac,
|
|
||||||
0xd2b1, 0xd2b8, 0xd2b9, 0xd2bc, 0xd2bf, 0xd2c0, 0xd2c2, 0xd2c8, 0xd2c9, 0xd2cb, 0xd2d4, 0xd2d8, 0xd2dc, 0xd2e4, 0xd2e5, 0xd2f0,
|
|
||||||
0xd2f1, 0xd2f4, 0xd2f8, 0xd300, 0xd301, 0xd303, 0xd305, 0xd30c, 0xd30d, 0xd30e, 0xd310, 0xd314, 0xd316, 0xd31c, 0xd31d, 0xd31f,
|
|
||||||
0xd320, 0xd321, 0xd325, 0xd328, 0xd329, 0xd32c, 0xd330, 0xd338, 0xd339, 0xd33b, 0xd33c, 0xd33d, 0xd344, 0xd345, 0xd37c, 0xd37d,
|
|
||||||
0xd380, 0xd384, 0xd38c, 0xd38d, 0xd38f, 0xd390, 0xd391, 0xd398, 0xd399, 0xd39c, 0xd3a0, 0xd3a8, 0xd3a9, 0xd3ab, 0xd3ad, 0xd3b4,
|
|
||||||
0xd3b8, 0xd3bc, 0xd3c4, 0xd3c5, 0xd3c8, 0xd3c9, 0xd3d0, 0xd3d8, 0xd3e1, 0xd3e3, 0xd3ec, 0xd3ed, 0xd3f0, 0xd3f4, 0xd3fc, 0xd3fd,
|
|
||||||
0xd3ff, 0xd401, 0xd408, 0xd41d, 0xd440, 0xd444, 0xd45c, 0xd460, 0xd464, 0xd46d, 0xd46f, 0xd478, 0xd479, 0xd47c, 0xd47f, 0xd480,
|
|
||||||
0xd482, 0xd488, 0xd489, 0xd48b, 0xd48d, 0xd494, 0xd4a9, 0xd4cc, 0xd4d0, 0xd4d4, 0xd4dc, 0xd4df, 0xd4e8, 0xd4ec, 0xd4f0, 0xd4f8,
|
|
||||||
0xd4fb, 0xd4fd, 0xd504, 0xd508, 0xd50c, 0xd514, 0xd515, 0xd517, 0xd53c, 0xd53d, 0xd540, 0xd544, 0xd54c, 0xd54d, 0xd54f, 0xd551,
|
|
||||||
0xd558, 0xd559, 0xd55c, 0xd560, 0xd565, 0xd568, 0xd569, 0xd56b, 0xd56d, 0xd574, 0xd575, 0xd578, 0xd57c, 0xd584, 0xd585, 0xd587,
|
|
||||||
0xd588, 0xd589, 0xd590, 0xd5a5, 0xd5c8, 0xd5c9, 0xd5cc, 0xd5d0, 0xd5d2, 0xd5d8, 0xd5d9, 0xd5db, 0xd5dd, 0xd5e4, 0xd5e5, 0xd5e8,
|
|
||||||
0xd5ec, 0xd5f4, 0xd5f5, 0xd5f7, 0xd5f9, 0xd600, 0xd601, 0xd604, 0xd608, 0xd610, 0xd611, 0xd613, 0xd614, 0xd615, 0xd61c, 0xd620,
|
|
||||||
0xd624, 0xd62d, 0xd638, 0xd639, 0xd63c, 0xd640, 0xd645, 0xd648, 0xd649, 0xd64b, 0xd64d, 0xd651, 0xd654, 0xd655, 0xd658, 0xd65c,
|
|
||||||
0xd667, 0xd669, 0xd670, 0xd671, 0xd674, 0xd683, 0xd685, 0xd68c, 0xd68d, 0xd690, 0xd694, 0xd69d, 0xd69f, 0xd6a1, 0xd6a8, 0xd6ac,
|
|
||||||
0xd6b0, 0xd6b9, 0xd6bb, 0xd6c4, 0xd6c5, 0xd6c8, 0xd6cc, 0xd6d1, 0xd6d4, 0xd6d7, 0xd6d9, 0xd6e0, 0xd6e4, 0xd6e8, 0xd6f0, 0xd6f5,
|
|
||||||
0xd6fc, 0xd6fd, 0xd700, 0xd704, 0xd711, 0xd718, 0xd719, 0xd71c, 0xd720, 0xd728, 0xd729, 0xd72b, 0xd72d, 0xd734, 0xd735, 0xd738,
|
|
||||||
0xd73c, 0xd744, 0xd747, 0xd749, 0xd750, 0xd751, 0xd754, 0xd756, 0xd757, 0xd758, 0xd759, 0xd760, 0xd761, 0xd763, 0xd765, 0xd769,
|
|
||||||
0xd76c, 0xd770, 0xd774, 0xd77c, 0xd77d, 0xd781, 0xd788, 0xd789, 0xd78c, 0xd790, 0xd798, 0xd799, 0xd79b, 0xd79d
|
|
||||||
};
|
|
||||||
|
|
||||||
uint16 ConvertKSToUCS2(uint16 code) {
|
uint16 ConvertKSToUCS2(uint16 code) {
|
||||||
uint16 c1 = code & 0xff;
|
// UHC is a superset of EUC-KR
|
||||||
uint16 c2 = code >> 8;
|
return Common::convertUHCToUCS(code & 0xff, code >> 8);
|
||||||
uint16 index = (c1 - 0xb0) * 94 + c2 - 0xa1;
|
|
||||||
assert(index < 2350);
|
|
||||||
|
|
||||||
return _ksToUcs2Table[index];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FontKorean *FontKorean::createFont(const char *fontFile) {
|
FontKorean *FontKorean::createFont(const char *fontFile) {
|
||||||
|
|
10
ports.mk
10
ports.mk
|
@ -386,10 +386,6 @@ ifdef USE_FRIBIDI
|
||||||
OSX_STATIC_LIBS += $(STATICLIBPATH)/lib/libfribidi.a
|
OSX_STATIC_LIBS += $(STATICLIBPATH)/lib/libfribidi.a
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef USE_ICONV
|
|
||||||
OSX_STATIC_LIBS += -liconv
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifdef USE_VORBIS
|
ifdef USE_VORBIS
|
||||||
OSX_STATIC_LIBS += \
|
OSX_STATIC_LIBS += \
|
||||||
$(STATICLIBPATH)/lib/libvorbisfile.a \
|
$(STATICLIBPATH)/lib/libvorbisfile.a \
|
||||||
|
@ -409,11 +405,7 @@ OSX_STATIC_LIBS += $(STATICLIBPATH)/lib/libogg.a
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef USE_FLUIDSYNTH
|
ifdef USE_FLUIDSYNTH
|
||||||
# If iconv was not yet added, add it now as we need it for libfluidsynth
|
OSX_STATIC_LIBS += -liconv \
|
||||||
ifndef USE_ICONV
|
|
||||||
OSX_STATIC_LIBS += -liconv
|
|
||||||
endif
|
|
||||||
OSX_STATIC_LIBS += \
|
|
||||||
-framework CoreMIDI -framework CoreAudio\
|
-framework CoreMIDI -framework CoreAudio\
|
||||||
$(STATICLIBPATH)/lib/libfluidsynth.a \
|
$(STATICLIBPATH)/lib/libfluidsynth.a \
|
||||||
$(STATICLIBPATH)/lib/libglib-2.0.a \
|
$(STATICLIBPATH)/lib/libglib-2.0.a \
|
||||||
|
|
267
test/common/encoding.h
Normal file
267
test/common/encoding.h
Normal file
|
@ -0,0 +1,267 @@
|
||||||
|
#include <cxxtest/TestSuite.h>
|
||||||
|
|
||||||
|
#include "common/str.h"
|
||||||
|
#include "common/ustr.h"
|
||||||
|
#include "../null_osystem.h"
|
||||||
|
|
||||||
|
class EncodingTestSuite : public CxxTest::TestSuite
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void test_korean() {
|
||||||
|
Common::install_null_g_system();
|
||||||
|
const byte utf8[] = {
|
||||||
|
0xea, 0xb2, 0x8c, 0xec, 0x9e, 0x84, 0xec, 0xa4,
|
||||||
|
0x91, 0xec, 0xa7, 0x80, 0x20, 0xea, 0xb3, 0x84,
|
||||||
|
0xec, 0x86, 0x8d, 0xed, 0x95, 0x98, 0xeb, 0xa0,
|
||||||
|
0xa4, 0xeb, 0xa9, 0xb4, 0x20, 0xec, 0x8a, 0xa4,
|
||||||
|
0xed, 0x8e, 0x98, 0xec, 0x9d, 0xb4, 0xec, 0x8a,
|
||||||
|
0xa4, 0xed, 0x82, 0xa4, 0xeb, 0xa5, 0xbc, 0x20,
|
||||||
|
0xec, 0xb9, 0x98, 0xec, 0x8b, 0x9c, 0xec, 0x98,
|
||||||
|
0xa4, 0x2e, 0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint32 utf32[] = {
|
||||||
|
0xac8c, 0xc784, 0xc911, 0xc9c0, 0x0020, 0xacc4,
|
||||||
|
0xc18d, 0xd558, 0xb824, 0xba74, 0x0020, 0xc2a4,
|
||||||
|
0xd398, 0xc774, 0xc2a4, 0xd0a4, 0xb97c, 0x0020,
|
||||||
|
0xce58, 0xc2dc, 0xc624, 0x002e, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
const byte uhc[] = {
|
||||||
|
0xb0, 0xd4, 0xc0, 0xd3, 0xc1, 0xdf, 0xc1, 0xf6,
|
||||||
|
0x20, 0xb0, 0xe8, 0xbc, 0xd3, 0xc7, 0xcf, 0xb7,
|
||||||
|
0xc1, 0xb8, 0xe9, 0x20, 0xbd, 0xba, 0xc6, 0xe4,
|
||||||
|
0xc0, 0xcc, 0xbd, 0xba, 0xc5, 0xb0, 0xb8, 0xa6,
|
||||||
|
0x20, 0xc4, 0xa1, 0xbd, 0xc3, 0xbf, 0xc0, 0x2e,
|
||||||
|
0x00
|
||||||
|
};
|
||||||
|
Common::U32String ustr_from_utf8((const char *) utf8, Common::kUtf8);
|
||||||
|
Common::U32String ustr_from_uhc((const char *) uhc, Common::kWindows949);
|
||||||
|
Common::U32String ustr(utf32);
|
||||||
|
Common::String utf8_to_uhc = ustr_from_utf8.encode(Common::kWindows949);
|
||||||
|
Common::String uhc_to_utf8 = ustr_from_uhc.encode(Common::kUtf8);
|
||||||
|
TS_ASSERT_EQUALS(ustr_from_utf8, ustr);
|
||||||
|
TS_ASSERT_EQUALS(ustr_from_uhc, ustr);
|
||||||
|
TS_ASSERT(strcmp((const char *) utf8, uhc_to_utf8.c_str()) == 0);
|
||||||
|
TS_ASSERT(strcmp((const char *) uhc, utf8_to_uhc.c_str()) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_chinese() {
|
||||||
|
Common::install_null_g_system();
|
||||||
|
const byte utf8[] = {
|
||||||
|
0xe9, 0x81, 0x8a, 0xe6, 0x88, 0xb2, 0xe6, 0x9a,
|
||||||
|
0xab, 0xe5, 0x81, 0x9c, 0xe3, 0x80, 0x82, 0xe6,
|
||||||
|
0x8c, 0x89, 0xe4, 0xb8, 0x8b, 0xe7, 0xa9, 0xba,
|
||||||
|
0x21, 0xe7, 0x99, 0xbd, 0xe9, 0x8d, 0xb5, 0xe7,
|
||||||
|
0xb9, 0xbc, 0xe7, 0xba, 0x8c, 0xe9, 0x81, 0x8a,
|
||||||
|
0xe6, 0x88, 0xb2, 0xe3, 0x80, 0x82, 0x00,
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint32 utf32[] = {
|
||||||
|
0x904a, 0x6232, 0x66ab, 0x505c, 0x3002, 0x6309,
|
||||||
|
0x4e0b, 0x7a7a, 0x0021, 0x767d, 0x9375, 0x7e7c,
|
||||||
|
0x7e8c, 0x904a, 0x6232, 0x3002, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
const byte big5[] = {
|
||||||
|
0xb9, 0x43, 0xc0, 0xb8, 0xbc, 0xc8, 0xb0, 0xb1,
|
||||||
|
0xa1, 0x43, 0xab, 0xf6, 0xa4, 0x55, 0xaa, 0xc5,
|
||||||
|
0x21, 0xa5, 0xd5, 0xc1, 0xe4, 0xc4, 0x7e, 0xc4,
|
||||||
|
0xf2, 0xb9, 0x43, 0xc0, 0xb8, 0xa1, 0x43, 0x00
|
||||||
|
};
|
||||||
|
Common::U32String ustr_from_utf8((const char *) utf8, Common::kUtf8);
|
||||||
|
Common::U32String ustr_from_big5((const char *) big5, Common::kWindows950);
|
||||||
|
Common::U32String ustr(utf32);
|
||||||
|
Common::String utf8_to_big5 = ustr_from_utf8.encode(Common::kWindows950);
|
||||||
|
Common::String big5_to_utf8 = ustr_from_big5.encode(Common::kUtf8);
|
||||||
|
TS_ASSERT_EQUALS(ustr_from_utf8, ustr);
|
||||||
|
TS_ASSERT_EQUALS(ustr_from_big5, ustr);
|
||||||
|
TS_ASSERT(strcmp((const char *) utf8, big5_to_utf8.c_str()) == 0);
|
||||||
|
TS_ASSERT(strcmp((const char *) big5, utf8_to_big5.c_str()) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_japanese() {
|
||||||
|
Common::install_null_g_system();
|
||||||
|
const byte utf8[] = {
|
||||||
|
0xe4, 0xb8, 0x80, 0xe6, 0x99, 0x82, 0xe5, 0x81,
|
||||||
|
0x9c, 0xe6, 0xad, 0xa2, 0xe3, 0x80, 0x82, 0xe7,
|
||||||
|
0xb6, 0x9a, 0xe3, 0x81, 0x91, 0xe3, 0x82, 0x8b,
|
||||||
|
0xe5, 0xa0, 0xb4, 0xe5, 0x90, 0x88, 0xe3, 0x81,
|
||||||
|
0xaf, 0xe3, 0x82, 0xb9, 0xe3, 0x83, 0x9a, 0xe3,
|
||||||
|
0x83, 0xbc, 0xe3, 0x82, 0xb9, 0xe3, 0x83, 0x90,
|
||||||
|
0xe3, 0x83, 0xbc, 0xe3, 0x82, 0x92, 0xe6, 0x8a,
|
||||||
|
0xbc, 0xe3, 0x81, 0x97, 0xe3, 0x81, 0xa6, 0xe3,
|
||||||
|
0x81, 0x8f, 0xe3, 0x81, 0xa0, 0xe3, 0x81, 0x95,
|
||||||
|
0xe3, 0x81, 0x84, 0xe3, 0x80, 0x82, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
const uint32 utf32[] = {
|
||||||
|
0x4e00, 0x6642, 0x505c, 0x6b62, 0x3002, 0x7d9a,
|
||||||
|
0x3051, 0x308b, 0x5834, 0x5408, 0x306f, 0x30b9,
|
||||||
|
0x30da, 0x30fc, 0x30b9, 0x30d0, 0x30fc, 0x3092,
|
||||||
|
0x62bc, 0x3057, 0x3066, 0x304f, 0x3060, 0x3055,
|
||||||
|
0x3044, 0x3002, 0
|
||||||
|
};
|
||||||
|
|
||||||
|
const byte cp932[] = {
|
||||||
|
0x88, 0xea, 0x8e, 0x9e, 0x92, 0xe2, 0x8e, 0x7e,
|
||||||
|
0x81, 0x42, 0x91, 0xb1, 0x82, 0xaf, 0x82, 0xe9,
|
||||||
|
0x8f, 0xea, 0x8d, 0x87, 0x82, 0xcd, 0x83, 0x58,
|
||||||
|
0x83, 0x79, 0x81, 0x5b, 0x83, 0x58, 0x83, 0x6f,
|
||||||
|
0x81, 0x5b, 0x82, 0xf0, 0x89, 0x9f, 0x82, 0xb5,
|
||||||
|
0x82, 0xc4, 0x82, 0xad, 0x82, 0xbe, 0x82, 0xb3,
|
||||||
|
0x82, 0xa2, 0x81, 0x42, 0
|
||||||
|
};
|
||||||
|
Common::U32String ustr_from_utf8((const char *) utf8, Common::kUtf8);
|
||||||
|
Common::U32String ustr_from_cp932((const char *) cp932, Common::kWindows932);
|
||||||
|
Common::U32String ustr(utf32);
|
||||||
|
Common::String utf8_to_cp932 = ustr_from_utf8.encode(Common::kWindows932);
|
||||||
|
Common::String cp932_to_utf8 = ustr_from_cp932.encode(Common::kUtf8);
|
||||||
|
TS_ASSERT_EQUALS(ustr_from_utf8, ustr);
|
||||||
|
TS_ASSERT_EQUALS(ustr_from_cp932, ustr);
|
||||||
|
TS_ASSERT(strcmp((const char *) utf8, cp932_to_utf8.c_str()) == 0);
|
||||||
|
TS_ASSERT(strcmp((const char *) cp932, utf8_to_cp932.c_str()) == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_conversion_unicode_machine_endian() {
|
||||||
|
Common::install_null_g_system();
|
||||||
|
// |dolar| cent | euro |
|
||||||
|
unsigned char utf8[] = {0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0};
|
||||||
|
#ifdef SCUMM_BIG_ENDIAN
|
||||||
|
//| dolar | cent | euro |
|
||||||
|
unsigned char utf16be[] = {0, 0x24, 0, 0xA2, 0x20, 0xAC, 0, 0};
|
||||||
|
//| dolar | cent | euro
|
||||||
|
unsigned char utf32be[] = {0, 0, 0, 0x24, 0, 0, 0, 0xA2, 0, 0, 0x20, 0xAC, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
unsigned char *utf16 = utf16be;
|
||||||
|
unsigned char *utf32 = utf32be;
|
||||||
|
#else
|
||||||
|
//| dolar | cent | euro |
|
||||||
|
unsigned char utf16le[] = {0x24, 0, 0xA2, 0, 0xAC, 0x20, 0, 0};
|
||||||
|
//| dolar | cent | euro
|
||||||
|
unsigned char utf32le[] = {0x24, 0, 0, 0, 0xA2, 0, 0, 0, 0xAC, 0x20, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
unsigned char *utf16 = utf16le;
|
||||||
|
unsigned char *utf32 = utf32le;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// UTF16 to UTF8
|
||||||
|
Common::String resultstr8 = Common::U32String::decodeUTF16Native((uint16 *) utf16, 3).encode(Common::kUtf8);
|
||||||
|
TS_ASSERT(resultstr8.c_str() != NULL);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(resultstr8.c_str(), utf8, 7), 0)
|
||||||
|
|
||||||
|
// UTF32 to UTF8
|
||||||
|
|
||||||
|
resultstr8 = Common::U32String((uint32 *) utf32, 3).encode(Common::kUtf8);
|
||||||
|
TS_ASSERT(resultstr8.c_str() != NULL);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(resultstr8.c_str(), utf8, 7), 0);
|
||||||
|
|
||||||
|
// UTF32 to UTF16
|
||||||
|
uint16 *result16 = Common::U32String((uint32 *) utf32, 3).encodeUTF16Native(NULL);
|
||||||
|
TS_ASSERT(result16 != NULL);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result16, utf16, 8), 0);
|
||||||
|
free(result16);
|
||||||
|
|
||||||
|
// UTF8 to UTF16
|
||||||
|
|
||||||
|
result16 = Common::U32String((char *) utf8, 6, Common::kUtf8).encodeUTF16Native(NULL);
|
||||||
|
TS_ASSERT(result16 != NULL);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result16, utf16, 8), 0);
|
||||||
|
free(result16);
|
||||||
|
|
||||||
|
// UTF8 to UTF32
|
||||||
|
Common::U32String resultustr = Common::String((const char *) utf8, 6).decode(Common::kUtf8);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(resultustr.c_str(), utf32, 16), 0);
|
||||||
|
|
||||||
|
// UTF16 to UTF32
|
||||||
|
resultustr = Common::U32String::decodeUTF16Native((uint16 *) utf16, 3);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(resultustr.c_str(), utf32, 16), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_conversion_unicode_big_endian() {
|
||||||
|
Common::install_null_g_system();
|
||||||
|
// |dolar| cent | euro |
|
||||||
|
unsigned char utf8[] = {0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0};
|
||||||
|
//| dolar | cent | euro |
|
||||||
|
unsigned char utf16be[] = {0, 0x24, 0, 0xA2, 0x20, 0xAC, 0, 0};
|
||||||
|
|
||||||
|
// UTF16 to UTF8
|
||||||
|
Common::String resultstr8 = Common::U32String::decodeUTF16BE((uint16 *) utf16be, 3).encode(Common::kUtf8);
|
||||||
|
TS_ASSERT(resultstr8.c_str() != NULL);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(resultstr8.c_str(), utf8, 7), 0);
|
||||||
|
|
||||||
|
|
||||||
|
// UTF8 to UTF16
|
||||||
|
uint16 *result16 = Common::U32String((char *) utf8, 6, Common::kUtf8).encodeUTF16BE(NULL);
|
||||||
|
TS_ASSERT(result16 != NULL);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result16, utf16be, 8), 0);
|
||||||
|
free(result16);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_conversion_unicode_little_endian() {
|
||||||
|
Common::install_null_g_system();
|
||||||
|
// |dolar| cent | euro |
|
||||||
|
unsigned char utf8[] = {0x24, 0xC2, 0xA2, 0xE2, 0x82, 0xAC, 0};
|
||||||
|
//| dolar | cent | euro |
|
||||||
|
unsigned char utf16le[] = {0x24, 0, 0xA2, 0, 0xAC, 0x20, 0, 0};
|
||||||
|
|
||||||
|
// UTF16 to UTF8
|
||||||
|
Common::String resultstr8 = Common::U32String::decodeUTF16LE((uint16 *) utf16le, 3).encode(Common::kUtf8);
|
||||||
|
TS_ASSERT(resultstr8.c_str() != NULL);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(resultstr8.c_str(), utf8, 7), 0);
|
||||||
|
|
||||||
|
// UTF8 to UTF16
|
||||||
|
uint16 *result16 = Common::U32String((char *) utf8, 6, Common::kUtf8).encodeUTF16LE(NULL);
|
||||||
|
TS_ASSERT(result16 != NULL);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result16, utf16le, 8), 0);
|
||||||
|
free(result16);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_cyrillic_transliteration() {
|
||||||
|
Common::install_null_g_system();
|
||||||
|
|
||||||
|
unsigned char utf8[] = {/* Z */0xD0, 0x97, /* d */ 0xD0, 0xB4, /* r */ 0xD1, 0x80, /* a */ 0xD0, 0xB0, /* v */ 0xD0, 0xB2, /* s */ 0xD1, 0x81, /* t */ 0xD1, 0x82, /* v */ 0xD0, 0xB2, /* u */ 0xD1, 0x83, /* j */ 0xD0, 0xB9, /* t */ 0xD1, 0x82, /* e */ 0xD0, 0xB5, 0};
|
||||||
|
unsigned char iso_8859_5[] = {0xB7, 0xD4, 0xE0, 0xD0, 0xD2, 0xE1, 0xE2, 0xD2, 0xE3, 0xD9, 0xE2, 0xD5, 0};
|
||||||
|
unsigned char ascii[] = "Zdravstvujte";
|
||||||
|
|
||||||
|
Common::String result = Common::U32String((const char *) utf8, 24, Common::kUtf8).encode(Common::kASCII);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result.c_str(), ascii, 13), 0);
|
||||||
|
|
||||||
|
result = Common::U32String((const char *) iso_8859_5, 12, Common::kISO8859_5).encode(Common::kASCII);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result.c_str(), ascii, 13), 0);
|
||||||
|
|
||||||
|
result = Common::U32String((const char *) iso_8859_5, 12, Common::kISO8859_5).encode(Common::kUtf8);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result.c_str(), utf8, 25), 0);
|
||||||
|
|
||||||
|
result = Common::U32String((const char *) utf8, 24, Common::kUtf8).encode(Common::kISO8859_5);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result.c_str(), iso_8859_5, 13), 0);
|
||||||
|
|
||||||
|
// this should stay the same
|
||||||
|
result = Common::U32String((const char *) ascii, 12, Common::kASCII).encode(Common::kISO8859_5);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result.c_str(), ascii, 13), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_other_conversions() {
|
||||||
|
Common::install_null_g_system();
|
||||||
|
|
||||||
|
unsigned char cp850[] = {0x99, 0xE0, 0xEA, 0x41, 0x64, 0};
|
||||||
|
unsigned char utf8_1[] = {0xC3, 0x96, 0xC3, 0x93, 0xC3, 0x9B, 0x41, 0x64, 0};
|
||||||
|
|
||||||
|
unsigned char iso_8859_2[] = {0xA9, 0xE1, 0x6C, 0x65, 0xE8, 0x65, 0x6B, 0};
|
||||||
|
unsigned char utf8_2[] = {0xC5, 0xA0, 0xC3, 0xA1, 0x6C, 0x65, 0xC4, 0x8D, 0x65, 0x6B, 0};
|
||||||
|
|
||||||
|
Common::String result = Common::U32String((const char *) cp850, 5, Common::kDos850).encode(Common::kUtf8);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result.c_str(), utf8_1, 9), 0);
|
||||||
|
|
||||||
|
result = Common::U32String((const char *) utf8_1, 8, Common::kUtf8).encode(Common::kDos850);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result.c_str(), cp850, 6), 0);
|
||||||
|
|
||||||
|
result = Common::U32String((const char *) iso_8859_2, 7, Common::kISO8859_2).encode(Common::kUtf8);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result.c_str(), utf8_2, 11), 0);
|
||||||
|
|
||||||
|
result = Common::U32String((const char *) utf8_2, 11, Common::kUtf8).encode(Common::kISO8859_2);
|
||||||
|
TS_ASSERT_EQUALS(memcmp(result.c_str(), iso_8859_2, 8), 0);
|
||||||
|
}
|
||||||
|
};
|
|
@ -6,7 +6,14 @@
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
TESTS := $(srcdir)/test/common/*.h $(srcdir)/test/audio/*.h $(srcdir)/test/math/*.h
|
TESTS := $(srcdir)/test/common/*.h $(srcdir)/test/audio/*.h $(srcdir)/test/math/*.h
|
||||||
TEST_LIBS := audio/libaudio.a math/libmath.a common/libcommon.a
|
TEST_LIBS := test/null_osystem.o \
|
||||||
|
backends/fs/posix/posix-fs-factory.o \
|
||||||
|
backends/fs/posix/posix-fs.o \
|
||||||
|
backends/fs/posix/posix-iostream.o \
|
||||||
|
backends/fs/stdiostream.o \
|
||||||
|
backends/modular-backend.o \
|
||||||
|
test/stubs.o \
|
||||||
|
audio/libaudio.a math/libmath.a common/libcommon.a
|
||||||
|
|
||||||
ifeq ($(ENABLE_WINTERMUTE), STATIC_PLUGIN)
|
ifeq ($(ENABLE_WINTERMUTE), STATIC_PLUGIN)
|
||||||
TESTS += $(srcdir)/test/engines/wintermute/*.h
|
TESTS += $(srcdir)/test/engines/wintermute/*.h
|
||||||
|
|
4
test/null_osystem.cpp
Normal file
4
test/null_osystem.cpp
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#define USE_NULL_DRIVER 1
|
||||||
|
#define NULL_DRIVER_USE_FOR_TEST 1
|
||||||
|
#include "null_osystem.h"
|
||||||
|
#include "../backends/platform/null/null.cpp"
|
3
test/null_osystem.h
Normal file
3
test/null_osystem.h
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
namespace Common {
|
||||||
|
void install_null_g_system();
|
||||||
|
}
|
181
test/stubs.cpp
Normal file
181
test/stubs.cpp
Normal file
|
@ -0,0 +1,181 @@
|
||||||
|
#include "backends/events/default/default-events.h"
|
||||||
|
#include "backends/timer/default/default-timer.h"
|
||||||
|
#include "backends/saves/default/default-saves.h"
|
||||||
|
#include "common/savefile.h"
|
||||||
|
#include "gui/message.h"
|
||||||
|
#include "backends/base-backend.h"
|
||||||
|
#include "backends/mixer/null/null-mixer.h"
|
||||||
|
#include "engines/engine.h"
|
||||||
|
|
||||||
|
Engine *g_engine = 0;
|
||||||
|
|
||||||
|
GUI::Debugger *Engine::getOrCreateDebugger() {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
NullMixerManager::NullMixerManager() : MixerManager() {
|
||||||
|
_outputRate = 22050;
|
||||||
|
_callsCounter = 0;
|
||||||
|
_samples = 8192;
|
||||||
|
while (_samples * 16 > _outputRate * 2)
|
||||||
|
_samples >>= 1;
|
||||||
|
_samplesBuf = new uint8[_samples * 4];
|
||||||
|
}
|
||||||
|
|
||||||
|
NullMixerManager::~NullMixerManager() {
|
||||||
|
delete []_samplesBuf;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NullMixerManager::update(uint8 callbackPeriod) {
|
||||||
|
if (_audioSuspended) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NullMixerManager::init() {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void NullMixerManager::suspendAudio() {
|
||||||
|
_audioSuspended = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
int NullMixerManager::resumeAudio() {
|
||||||
|
if (!_audioSuspended) {
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
_audioSuspended = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultEventManager::DefaultEventManager(Common::EventSource *boss) :
|
||||||
|
_buttonState(0),
|
||||||
|
_modifierState(0),
|
||||||
|
_shouldQuit(false),
|
||||||
|
_shouldReturnToLauncher(false),
|
||||||
|
_confirmExitDialogActive(false) {
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultEventManager::~DefaultEventManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultEventManager::init() {
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DefaultEventManager::pollEvent(Common::Event &event) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultEventManager::pushEvent(const Common::Event &event) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultEventManager::purgeMouseEvents() {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::Keymap *DefaultEventManager::getGlobalKeymap() {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultTimerManager::DefaultTimerManager() :
|
||||||
|
_timerCallbackNext(0),
|
||||||
|
_head(0) {
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultTimerManager::~DefaultTimerManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultTimerManager::handler() {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultTimerManager::checkTimers(uint32 interval) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DefaultTimerManager::installTimerProc(TimerProc callback, int32 interval, void *refCon, const Common::String &id) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultTimerManager::removeTimerProc(TimerProc callback) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultSaveFileManager::DefaultSaveFileManager() {
|
||||||
|
}
|
||||||
|
|
||||||
|
DefaultSaveFileManager::DefaultSaveFileManager(const Common::String &defaultSavepath) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DefaultSaveFileManager::checkPath(const Common::FSNode &dir) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultSaveFileManager::updateSavefilesList(Common::StringArray &lockedFiles) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::StringArray DefaultSaveFileManager::listSavefiles(const Common::String &pattern) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::InSaveFile *DefaultSaveFileManager::openRawFile(const Common::String &filename) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::InSaveFile *DefaultSaveFileManager::openForLoading(const Common::String &filename) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::OutSaveFile *DefaultSaveFileManager::openForSaving(const Common::String &filename, bool compress) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DefaultSaveFileManager::removeSavefile(const Common::String &filename) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::String DefaultSaveFileManager::getSavePath() const {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DefaultSaveFileManager::assureCached(const Common::String &savePathName) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::String DefaultSaveFileManager::concatWithSavesPath(Common::String name) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Common::SaveFileManager::copySavefile(const Common::String &oldFilename, const Common::String &newFilename, bool compress) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Common::SaveFileManager::renameSavefile(const Common::String &oldFilename, const Common::String &newFilename, bool compress) {
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Common::String Common::SaveFileManager::popErrorDesc() {
|
||||||
|
Common::String err = _errorDesc;
|
||||||
|
clearError();
|
||||||
|
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseBackend::displayMessageOnOSD(const Common::U32String &msg) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseBackend::initBackend() {
|
||||||
|
OSystem::initBackend();
|
||||||
|
}
|
||||||
|
|
||||||
|
void BaseBackend::fillScreen(uint32 col) {
|
||||||
|
}
|
||||||
|
|
||||||
|
void EventsBaseBackend::initBackend() {
|
||||||
|
BaseBackend::initBackend();
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue