Solution refactoring and restructuring, removed Boost dependency, removed unused tools

This commit is contained in:
2022-11-21 23:42:01 +02:00
parent 33f19f9ff6
commit 9ef9f39e88
817 changed files with 326 additions and 59698 deletions

366
src/EterLocale/Arabic.cpp Normal file
View File

@ -0,0 +1,366 @@
#include "StdAfx.h"
#include "Arabic.h"
#include <assert.h>
enum ARABIC_CODE
{
ARABIC_CODE_BASE = 0x0621,
ARABIC_CODE_LAST = 0x064a,
ARABIC_CODE_COUNT = ARABIC_CODE_LAST - ARABIC_CODE_BASE + 1,
};
enum ARABIC_FORM_TYPE
{
DEBUG_CODE,
ISOLATED,
INITIAL,
MEDIAL,
FINAL,
ARABIC_FORM_TYPE_NUM,
};
bool Arabic_IsInSpace(wchar_t code)
{
switch (code)
{
case ' ':
case '\t':
return true;
default:
return false;
}
}
bool Arabic_IsInSymbol(wchar_t code)
{
return (code >= 0x20 && code <= 0x2f) ||
(code >= 0x3a && code <= 0x40) ||
(code >= 0x5b && code <= 0x60) ||
(code >= 0x7b && code <= 0x7e);
}
bool Arabic_IsInPresentation(wchar_t code)
{
return (code >= 0xfb50 && code <= 0xfdff) || (code >= 0xfe70 && code <= 0xfeff) || (code == 0x08);
}
bool Arabic_HasPresentation(wchar_t* codes, int last)
{
while (last > 0)
{
if (Arabic_IsInSpace(codes[last]))
{
last--;
}
else
{
if (Arabic_IsInPresentation(codes[last]))
return true;
else
break;
}
}
return false;
}
wchar_t Arabic_GetComposition(wchar_t cur, wchar_t next, ARABIC_FORM_TYPE pos)
{
static wchar_t LAM_ALEF_MADDA[ARABIC_FORM_TYPE_NUM] = {0x0622, 0xFEF5, 0, 0, 0xFEF6};
static wchar_t LAM_ALEF_HAMZA_ABOVE[ARABIC_FORM_TYPE_NUM] = {0x0623, 0xFEF7, 0, 0, 0xFEF8};
static wchar_t LAM_ALEF_HAMZA_BELOW[ARABIC_FORM_TYPE_NUM] = {0x0625, 0xFEF9, 0, 0, 0xFEFA};
static wchar_t LAM_ALEF[ARABIC_FORM_TYPE_NUM] = {0x0627, 0xFEFB, 0, 0, 0xFEFC};
switch (cur)
{
case 0x0644:
switch (next)
{
case 0x0622:return LAM_ALEF_MADDA[pos];break;
case 0x0623:return LAM_ALEF_HAMZA_ABOVE[pos];break;
case 0x0625:return LAM_ALEF_HAMZA_BELOW[pos];break;
case 0x0627:return LAM_ALEF[pos];break;
}
break;
}
return 0;
}
wchar_t Arabic_GetMap(wchar_t code, ARABIC_FORM_TYPE pos)
{
static wchar_t HAMZA[ARABIC_FORM_TYPE_NUM] = {0x0621 , 0xFE80, 0, 0, 0};
static wchar_t ALEF_MADDA[ARABIC_FORM_TYPE_NUM] = {0x0622 , 0xFE81, 0, 0, 0xFE82};
static wchar_t ALEF_HAMZA_ABOVE[ARABIC_FORM_TYPE_NUM] = {0x0623 , 0xFE83, 0, 0, 0xFE84};
static wchar_t WAW_HAMZA[ARABIC_FORM_TYPE_NUM] = {0x0624 , 0xFE85, 0, 0, 0xFE86};
static wchar_t ALEF_HAMZA_BELOW[ARABIC_FORM_TYPE_NUM] = {0x0625 , 0xFE87, 0, 0, 0xFE88};
static wchar_t YEH_HAMZA[ARABIC_FORM_TYPE_NUM] = {0x0626 , 0xFE89, 0xFE8B, 0xFE8C, 0xFE8A};
static wchar_t ALEF[ARABIC_FORM_TYPE_NUM] = {0x0627 , 0xFE8D, 0, 0, 0xFE8E};
static wchar_t BEH[ARABIC_FORM_TYPE_NUM] = {0x0628 , 0xFE8F, 0xFE91, 0xFE92, 0xFE90};
static wchar_t TEH_MARBUTA[ARABIC_FORM_TYPE_NUM] = {0x0629 , 0xFE93, 0, 0, 0xFE94};
static wchar_t TEH[ARABIC_FORM_TYPE_NUM] = {0x062A , 0xFE95, 0xFE97, 0xFE98, 0xFE96};
static wchar_t THEH[ARABIC_FORM_TYPE_NUM] = {0x062B , 0xFE99, 0xFE9B, 0xFE9C, 0xFE9A};
static wchar_t JEEM[ARABIC_FORM_TYPE_NUM] = {0x062C , 0xFE9D, 0xFE9F, 0xFEA0, 0xFE9E};
static wchar_t HAH[ARABIC_FORM_TYPE_NUM] = {0x062D , 0xFEA1, 0xFEA3, 0xFEA4, 0xFEA2};
static wchar_t KHAH[ARABIC_FORM_TYPE_NUM] = {0x062E , 0xFEA5, 0xFEA7, 0xFEA8, 0xFEA6};
static wchar_t DAL[ARABIC_FORM_TYPE_NUM] = {0x062F , 0xFEA9, 0, 0, 0xFEAA};
static wchar_t THAL[ARABIC_FORM_TYPE_NUM] = {0x0630 , 0xFEAB, 0, 0, 0xFEAC};
static wchar_t REH[ARABIC_FORM_TYPE_NUM] = {0x0631 , 0xFEAD, 0, 0, 0xFEAE};
static wchar_t ZAIN[ARABIC_FORM_TYPE_NUM] = {0x0632 , 0xFEAF, 0, 0, 0xFEB0};
static wchar_t SEEN[ARABIC_FORM_TYPE_NUM] = {0x0633 , 0xFEB1, 0xFEB3, 0xFEB4, 0xFEB2};
static wchar_t SHEEN[ARABIC_FORM_TYPE_NUM] = {0x0634 , 0xFEB5, 0xFEB7, 0xFEB8, 0xFEB6};
static wchar_t SAD[ARABIC_FORM_TYPE_NUM] = {0x0635 , 0xFEB9, 0xFEBB, 0xFEBC, 0xFEBA};
static wchar_t DAD[ARABIC_FORM_TYPE_NUM] = {0x0636 , 0xFEBD, 0xFEBF, 0xFEC0, 0xFEBE};
static wchar_t TAH[ARABIC_FORM_TYPE_NUM] = {0x0637 , 0xFEC1, 0xFEC3, 0xFEC4, 0xFEC2};
static wchar_t ZAH[ARABIC_FORM_TYPE_NUM] = {0x0638 , 0xFEC5, 0xFEC7, 0xFEC8, 0xFEC6};
static wchar_t AIN[ARABIC_FORM_TYPE_NUM] = {0x0639 , 0xFEC9, 0xFECB, 0xFECC, 0xFECA};
static wchar_t GHAIN[ARABIC_FORM_TYPE_NUM] = {0x063A , 0xFECD, 0xFECF, 0xFED0, 0xFECE};
static wchar_t TATWEEL[ARABIC_FORM_TYPE_NUM] = {0x0640 , 0x0640, 0, 0, 0};
static wchar_t OX_FEH[ARABIC_FORM_TYPE_NUM] = {0x0641 , 0xFED1, 0xFED3, 0xFED4, 0xFED2};
static wchar_t QAF[ARABIC_FORM_TYPE_NUM] = {0x0642 , 0xFED5, 0xFED7, 0xFED8, 0xFED6};
static wchar_t KAF[ARABIC_FORM_TYPE_NUM] = {0x0643 , 0xFED9, 0xFEDB, 0xFEDC, 0xFEDA};
static wchar_t LAM[ARABIC_FORM_TYPE_NUM] = {0x0644 , 0xFEDD, 0xFEDF, 0xFEE0, 0xFEDE};
static wchar_t MEEM[ARABIC_FORM_TYPE_NUM] = {0x0645 , 0xFEE1, 0xFEE3, 0xFEE4, 0xFEE2};
static wchar_t NOON[ARABIC_FORM_TYPE_NUM] = {0x0646 , 0xFEE5, 0xFEE7, 0xFEE8, 0xFEE6};
static wchar_t HEH[ARABIC_FORM_TYPE_NUM] = {0x0647 , 0xFEE9, 0xFEEB, 0xFEEC, 0xFEEA};
static wchar_t WAW[ARABIC_FORM_TYPE_NUM] = {0x0648 , 0xFEED, 0, 0, 0xFEEE};
static wchar_t ALEF_MAKSURA[ARABIC_FORM_TYPE_NUM] = {0x0649 , 0xFEEF, 0, 0, 0xFEF0};
static wchar_t YEH[ARABIC_FORM_TYPE_NUM] = {0x064A , 0xFEF1, 0xFEF3, 0xFEF4, 0xFEF2};
switch (code)
{
case 0x0621: return HAMZA[pos];break;
case 0x0622: return ALEF_MADDA[pos];break;
case 0x0623: return ALEF_HAMZA_ABOVE[pos];break;
case 0x0624: return WAW_HAMZA[pos];break;
case 0x0625: return ALEF_HAMZA_BELOW[pos];break;
case 0x0626: return YEH_HAMZA[pos];break;
case 0x0627: return ALEF[pos];break;
case 0x0628: return BEH[pos];break;
case 0x0629: return TEH_MARBUTA[pos];break;
case 0x062A: return TEH[pos];break;
case 0x062B: return THEH[pos];break;
case 0x062C: return JEEM[pos];break;
case 0x062D: return HAH[pos];break;
case 0x062E: return KHAH[pos];break;
case 0x062F: return DAL[pos];break;
case 0x0630: return THAL[pos];break;
case 0x0631: return REH[pos];break;
case 0x0632: return ZAIN[pos];break;
case 0x0633: return SEEN[pos];break;
case 0x0634: return SHEEN[pos];break;
case 0x0635: return SAD[pos];break;
case 0x0636: return DAD[pos];break;
case 0x0637: return TAH[pos];break;
case 0x0638: return ZAH[pos];break;
case 0x0639: return AIN[pos];break;
case 0x063A: return GHAIN[pos];break;
case 0x0640: return TATWEEL[pos];break;
case 0x0641: return OX_FEH[pos];break;
case 0x0642: return QAF[pos];break;
case 0x0643: return KAF[pos];break;
case 0x0644: return LAM[pos];break;
case 0x0645: return MEEM[pos];break;
case 0x0646: return NOON[pos];break;
case 0x0647: return HEH[pos];break;
case 0x0648: return WAW[pos];break;
case 0x0649: return ALEF_MAKSURA[pos];break;
case 0x064A: return YEH[pos];break;
}
return 0;
}
bool Arabic_IsInMap(wchar_t code)
{
return (code >= ARABIC_CODE_BASE && code <= ARABIC_CODE_LAST);
}
bool Arabic_IsInComposing(wchar_t code)
{
switch (code)
{
case 0x064B: // FATHATAN
case 0x064C: // DAMMATAN
case 0x064D: // KASRATAN
case 0x064E: // FATHA
case 0x064F: // DAMMA
case 0x0650: // KASRA
case 0x0651: // SHADDA
case 0x0652: // SUKUN
case 0x0653: // MADDAH ABOVE
case 0x0654: // HAMZA ABOVE
case 0x0655: // HAMZA BELOW
case 0x0670: // SUPERSCRIPT ALEF
case 0x06D6: // HIGH LIG. SAD WITH LAM WITH ALEF MAKSURA
case 0x06D7: // HIGH LIG. QAF WITH LAM WITH ALEF MAKSURA
case 0x06D8: // HIGH MEEM INITIAL FORM
case 0x06D9: // HIGH LAM ALEF
case 0x06DA: // HIGH JEEM
case 0x06DB: // HIGH THREE DOTS
case 0x06DC: // HIGH SEEN
// The 2 entires below should not be here - contact unicode.org !!
// case 0x06DD: // END OF AYAH
// case 0x06DE: // START OF RUB EL HIZB
case 0x06DF: // HIGH ROUNDED ZERO
case 0x06E0: // HIGH UPRIGHT RECTANGULAR ZERO
case 0x06E1: // HIGH DOTLESS HEAD OF KHAH
case 0x06E2: // HIGH MEEM ISOLATED FORM
case 0x06E3: // LOW SEEN
case 0x06E4: // HIGH MADDA
case 0x06E7: // HIGH YEH
case 0x06E8: // HIGH NOON
case 0x06EA: // EMPTY CENTRE LOW STOP
case 0x06EB: // EMPTY CENTRE HIGH STOP
case 0x06EC: // HIGH STOP WITH FILLED CENTRE
case 0x06ED: // LOW MEEM
return true;
}
return false;
}
bool Arabic_IsNext(wchar_t code)
{
return (code == 0x0640);
}
bool Arabic_IsComb1(wchar_t code)
{
return (code == 0x0644);
}
bool Arabic_IsComb2(wchar_t code)
{
switch (code)
{
case 0x0622:
case 0x0623:
case 0x0625:
case 0x0627:
return true;
}
return false;
}
size_t Arabic_MakeShape(wchar_t* src, size_t srcLen, wchar_t* dst, size_t dstLen)
{
assert(dstLen >= srcLen);
const size_t srcLastIndex = srcLen - 1;
unsigned dstIndex = 0;
for (size_t srcIndex = 0; srcIndex < srcLen; ++srcIndex)
{
wchar_t cur = src[srcIndex];
//printf("now %x\n", cur);
if (Arabic_IsInMap(cur))
{
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EEB3BB>
wchar_t prev = 0;
{
size_t prevIndex = srcIndex;
while (prevIndex > 0)
{
prevIndex--;
prev = src[prevIndex];
//printf("\tprev %d:%x\n", prevIndex, cur);
if (Arabic_IsInComposing(prev))
continue;
else
break;
}
if ((srcIndex == 0) ||
(!Arabic_IsInMap(prev)) ||
(!Arabic_GetMap(prev, INITIAL) && !Arabic_GetMap(prev, MEDIAL)))
{
//printf("\tprev not defined\n");
prev = 0;
}
}
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EEB3BB>
wchar_t next = 0;
{
size_t nextIndex = srcIndex;
while (nextIndex < srcLastIndex)
{
nextIndex++;
next = src[nextIndex];
if (Arabic_IsInComposing(next))
continue;
else
break;
}
if ((nextIndex == srcLen) ||
(!Arabic_IsInMap(next)) ||
(!Arabic_GetMap(next, MEDIAL) && !Arabic_GetMap(next, FINAL) && !Arabic_IsNext(next)))
{
//printf("\tnext not defined\n");
next = 0;
}
}
if (Arabic_IsComb1(cur) && Arabic_IsComb2(next))
{
if (prev)
dst[dstIndex] = Arabic_GetComposition(cur, next, FINAL);
else
dst[dstIndex] = Arabic_GetComposition(cur, next, ISOLATED);
//printf("\tGot me a complex:%x\n", dst[dstIndex]);
srcIndex++;
dstIndex++;
}
else if (prev && next && (dst[dstIndex] = Arabic_GetMap(cur, MEDIAL)))
{
//printf("\tGot prev & next:%x\n", dst[dstIndex]);
dstIndex++;
}
else if (prev && (dst[dstIndex] = Arabic_GetMap(cur, FINAL)))
{
//printf("\tGot prev:%x\n", dst[dstIndex]);
dstIndex++;
}
else if (next && (dst[dstIndex] = Arabic_GetMap(cur, INITIAL)))
{
//printf("\tGot next:%x\n", dst[dstIndex]);
dstIndex++;
}
else
{
dst[dstIndex] = Arabic_GetMap(cur, ISOLATED);
//printf("\tGot nothing:%x\n", dst[dstIndex]);
dstIndex++;
}
}
else
{
dst[dstIndex] = cur;
dstIndex++;
}
}
return dstIndex;
}
wchar_t Arabic_ConvSymbol(wchar_t c)
{
switch (c)
{
case '(': return')';break;
case ')': return'(';break;
case '<': return'>';break;
case '>': return'<';break;
case '{': return'}';break;
case '}': return'{';break;
case '[': return']';break;
case ']': return '[';break;
default:
return c;
}
}

11
src/EterLocale/Arabic.h Normal file
View File

@ -0,0 +1,11 @@
#pragma once
wchar_t Arabic_ConvSymbol(wchar_t c);
bool Arabic_IsInSpace(wchar_t code);
bool Arabic_IsInSymbol(wchar_t code);
bool Arabic_IsInPresentation(wchar_t code);
bool Arabic_HasPresentation(wchar_t* codes, int last);
size_t Arabic_MakeShape(wchar_t* src, size_t srcLen, wchar_t* dst, size_t dstLen);
wchar_t Arabic_ConvEnglishModeSymbol(wchar_t code);

View File

@ -0,0 +1,46 @@
#pragma once
#define CP_874 874 // Thai
#define CP_THAI CP_874
#define CP_932 932 // Japanese
#define CP_JAPANESE CP_932
#define CP_936 936 // Chinese(Simplefied)
#define CP_CHINESE_SIMPLE CP_936
#define CP_949 949 // Hangeul
#define CP_HANGUL CP_949
#define CP_950 950 // Chinese(Traditional)
#define CP_CHINESE_TRAD CP_950
#define CP_1250 1250 // Middle and East Europe
#define CP_EASTEUROPE CP_1250
#define CP_1251 1251 // Cyrillic
#define CP_CYRILLIC CP_1251
#define CP_1252 1252 // Latin
#define CP_LATIN CP_1252
#define CP_1253 1253 // Greek
#define CP_GREEK CP_1253
#define CP_1254 1254 // Turkish
#define CP_TURKISH CP_1254
#define CP_1255 1255 // Hebrew
#define CP_HEBREW CP_1255
#define CP_1256 1256 // Aralic
#define CP_ARABIC CP_1256
#define CP_1257 1257 // Baltic
#define CP_BALTIC CP_1257
#define CP_1258 1258 // Vietnamese
#define CP_VIETNAMESE CP_1258
#define CP_65001 65001 // UTF-8
//#define CP_UTF8 65001 // UTF-8 translation

View File

@ -0,0 +1,346 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Distribute|Win32">
<Configuration>Distribute</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="MfcDebug|Win32">
<Configuration>MfcDebug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="MfcRelease|Win32">
<Configuration>MfcRelease</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="VTune|Win32">
<Configuration>VTune</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<ProjectName>EterLocale</ProjectName>
<ProjectGuid>{05207E97-C83A-49C6-8E08-403679963A7B}</ProjectGuid>
<RootNamespace>EterLocale</RootNamespace>
<SccProjectName>SAK</SccProjectName>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
<SccProvider>SAK</SccProvider>
<Keyword>MFCProj</Keyword>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>Static</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
<UseOfMfc>false</UseOfMfc>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>17.0.32203.90</_ProjectFileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)build\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<VcpkgUseStatic>true</VcpkgUseStatic>
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
<VcpkgUseStatic>true</VcpkgUseStatic>
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
</PropertyGroup>
<PropertyGroup Label="Vcpkg" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<VcpkgUseStatic>true</VcpkgUseStatic>
<VcpkgConfiguration>$(Configuration)</VcpkgConfiguration>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeaderOutputFile>.\Distribute/EterLocale.pch</PrecompiledHeaderOutputFile>
<AssemblerOutput>All</AssemblerOutput>
<AssemblerListingLocation>.\Distribute/</AssemblerListingLocation>
<ObjectFileName>.\Distribute/</ObjectFileName>
<ProgramDataBaseFileName>.\Distribute/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader />
<PrecompiledHeaderOutputFile>.\MfcRelease/EterLocale.pch</PrecompiledHeaderOutputFile>
<AssemblerOutput>All</AssemblerOutput>
<AssemblerListingLocation>.\MfcRelease/</AssemblerListingLocation>
<ObjectFileName>.\MfcRelease/</ObjectFileName>
<ProgramDataBaseFileName>.\MfcRelease/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
</ResourceCompile>
<Lib>
<OutputFile>.\MfcRelease\EterLocale.lib</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">
<ClCompile>
<AdditionalOptions>/Gs %(AdditionalOptions)</AdditionalOptions>
<Optimization>Disabled</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<FavorSizeOrSpeed>Size</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeaderOutputFile>.\VTune/EterLocale.pch</PrecompiledHeaderOutputFile>
<AssemblerOutput>All</AssemblerOutput>
<AssemblerListingLocation>.\VTune/</AssemblerListingLocation>
<ObjectFileName>.\VTune/</ObjectFileName>
<ProgramDataBaseFileName>.\VTune/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
</ResourceCompile>
<Lib>
<OutputFile>.\VTune\EterLocale.lib</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>.;../../extern/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<PrecompiledHeader />
<PrecompiledHeaderOutputFile>.\MfcDebug/EterLocale.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\MfcDebug/</AssemblerListingLocation>
<ObjectFileName>.\MfcDebug/</ObjectFileName>
<ProgramDataBaseFileName>.\MfcDebug/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
</ResourceCompile>
<Lib>
<OutputFile>.\MfcDebug\EterLocale.lib</OutputFile>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<StringPooling>true</StringPooling>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeaderOutputFile>.\Release/EterLocale.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\Release/</AssemblerListingLocation>
<ObjectFileName>.\Release/</ObjectFileName>
<ProgramDataBaseFileName>.\Release/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(SolutionDir)extern\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader />
<PrecompiledHeaderFile>StdAfx.h</PrecompiledHeaderFile>
<PrecompiledHeaderOutputFile>.\Debug/EterLocale.pch</PrecompiledHeaderOutputFile>
<AssemblerListingLocation>.\Debug/</AssemblerListingLocation>
<ObjectFileName>.\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
<BrowseInformation />
<WarningLevel>Level3</WarningLevel>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<CompileAs>Default</CompileAs>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
</ClCompile>
<ResourceCompile>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<Culture>0x0412</Culture>
<IgnoreStandardIncludePath>true</IgnoreStandardIncludePath>
</ResourceCompile>
<Lib>
<SuppressStartupBanner>true</SuppressStartupBanner>
</Lib>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Arabic.cpp" />
<ClCompile Include="Japanese.cpp" />
<ClCompile Include="StdAfx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Distribute|Win32'">stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='MfcDebug|Win32'">stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='MfcRelease|Win32'">stdafx.h</PrecompiledHeaderFile>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">stdafx.h</PrecompiledHeaderFile>
<FavorSizeOrSpeed Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Size</FavorSizeOrSpeed>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">Create</PrecompiledHeader>
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='VTune|Win32'">stdafx.h</PrecompiledHeaderFile>
</ClCompile>
<ClCompile Include="StringCodec.cpp" />
<ClCompile Include="StringCodec_Vietnamese.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="Arabic.h" />
<ClInclude Include="CodePageId.h" />
<ClInclude Include="Japanese.h" />
<ClInclude Include="StdAfx.h" />
<ClInclude Include="StringCodec.h" />
<ClInclude Include="StringCodec_Vietnamese.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="StringUtility">
<UniqueIdentifier>{d970d331-81ab-4b34-ac5c-1381d7750da4}</UniqueIdentifier>
</Filter>
<Filter Include="Core">
<UniqueIdentifier>{21d98c77-7ef4-47ec-95b6-5cdc79bcb5b7}</UniqueIdentifier>
</Filter>
<Filter Include="StringCodec">
<UniqueIdentifier>{9d104e97-4684-471d-87dc-e4baddee8b2d}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Arabic.cpp">
<Filter>StringUtility</Filter>
</ClCompile>
<ClCompile Include="Japanese.cpp">
<Filter>StringUtility</Filter>
</ClCompile>
<ClCompile Include="StdAfx.cpp">
<Filter>Core</Filter>
</ClCompile>
<ClCompile Include="StringCodec.cpp">
<Filter>StringCodec</Filter>
</ClCompile>
<ClCompile Include="StringCodec_Vietnamese.cpp">
<Filter>StringCodec</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Arabic.h">
<Filter>StringUtility</Filter>
</ClInclude>
<ClInclude Include="Japanese.h">
<Filter>StringUtility</Filter>
</ClInclude>
<ClInclude Include="CodePageId.h">
<Filter>Core</Filter>
</ClInclude>
<ClInclude Include="StdAfx.h">
<Filter>Core</Filter>
</ClInclude>
<ClInclude Include="StringCodec.h">
<Filter>StringCodec</Filter>
</ClInclude>
<ClInclude Include="StringCodec_Vietnamese.h">
<Filter>StringCodec</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -0,0 +1,71 @@
#include "StdAfx.h"
#include "Japanese.h"
//
// CP932: Shift-JIS (Japan Industry Standard)
//
#define MACRO_IsLeadByte(c) ((0x81 <= (c) && (c) <= 0x9f) || ((0xe0 <= (c)) && (c) <= 0xfc))
#define MACRO_IsTailByte(c) ((0x40 <= (c) && (c) <= 0x7e) || (0x80 <= (c) && (c) <= 0xfc))
BOOL ShiftJIS_IsLeadByte( const char chByte )
{
const unsigned char byByte = (const unsigned char) chByte;
return MACRO_IsLeadByte( byByte );
}
BOOL ShiftJIS_IsTrailByte( const char chByte )
{
const unsigned char byByte = (const unsigned char) chByte;
return MACRO_IsTailByte( byByte );
}
int ShiftJIS_StringCompareCI( LPCSTR szStringLeft, LPCSTR szStringRight, size_t sizeLength )
{
const unsigned char* uszString1 = (const unsigned char*) szStringLeft;
const unsigned char* uszString2 = (const unsigned char*) szStringRight;
unsigned short c1, c2;
if( sizeLength == 0 )
return 0;
while( sizeLength-- ) {
c1 = *uszString1++;
if( MACRO_IsLeadByte(c1) ) {
if( sizeLength == 0 ) {
c1 = 0;
c2 = MACRO_IsLeadByte( *uszString2 ) ? 0 : *uszString2;
goto test;
}
if( *uszString1 == '\0' )
c1 = 0;
else {
c1 = ((c1 << 8) | *uszString1++);
}
} else
c1 = tolower(c1);
c2 = *uszString2++;
if( MACRO_IsLeadByte(c2) ) {
if( sizeLength == 0 ) {
c2 = 0;
goto test;
}
sizeLength--;
if( *uszString2 == '\0' )
c2 = 0;
else {
c2 = ((c2 << 8) | *uszString2++);
}
} else
c2 = tolower(c2);
test:
if (c1 != c2)
return( (c1 > c2) ? 1 : -1);
if (c1 == 0)
return(0);
}
return 0;
}

View File

@ -0,0 +1,5 @@
#pragma once
BOOL ShiftJIS_IsLeadByte( const char chByte );
BOOL ShiftJIS_IsTrailByte( const char chByte );
int ShiftJIS_StringCompareCI( LPCSTR szStringLeft, LPCSTR szStringRight, size_t sizeLength );

View File

@ -0,0 +1,6 @@
// stdafx.cpp : source file that includes just the standard includes
// eterImageLib.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"

13
src/EterLocale/StdAfx.h Normal file
View File

@ -0,0 +1,13 @@
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <assert.h>
#include "CodePageId.h"

View File

@ -0,0 +1,43 @@
#include "stdafx.h"
#include "StringCodec.h"
#include "StringCodec_Vietnamese.h"
int Ymir_WideCharToMultiByte(
UINT CodePage,
DWORD dwFlags,
LPCWSTR lpWideCharStr,
int cchWideChar,
LPSTR lpMultiByteStr,
int cbMultiByte,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar
)
{
if (CodePage == CP_1258)
{
return EL_String_Encode_Vietnamese(lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte);
}
else
{
return WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte, lpDefaultChar, lpUsedDefaultChar);
}
}
int Ymir_MultiByteToWideChar(
UINT CodePage,
DWORD dwFlags,
LPCSTR lpMultiByteStr,
int cbMultiByte,
LPWSTR lpWideCharStr,
int cchWideChar
)
{
if (CodePage == CP_1258)
{
return EL_String_Decode_Vietnamese(lpMultiByteStr, cbMultiByte, lpWideCharStr, cchWideChar);
}
else
{
return MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, lpWideCharStr, cchWideChar);
}
}

View File

@ -0,0 +1,21 @@
#pragma once
int Ymir_WideCharToMultiByte(
UINT CodePage,
DWORD dwFlags,
LPCWSTR lpWideCharStr,
int cchWideChar,
LPSTR lpMultiByteStr,
int cbMultiByte,
LPCSTR lpDefaultChar,
LPBOOL lpUsedDefaultChar
);
int Ymir_MultiByteToWideChar(
UINT CodePage,
DWORD dwFlags,
LPCSTR lpMultiByteStr,
int cbMultiByte,
LPWSTR lpWideCharStr,
int cchWideChar
);

View File

@ -0,0 +1,554 @@
#include "stdafx.h"
#include "StringCodec_Vietnamese.h"
#pragma warning(disable: 4310) // char 짤림 경고 무시
static wchar_t cp1258_to_unicode[256] = {
0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
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, 0x007f,
0x20ac, 0x0081, 0x201a, 0x0192, 0x201e, 0x2026, 0x2020, 0x2021, //0x80
0x02c6, 0x2030, 0x008a, 0x2039, 0x0152, 0x008d, 0x008e, 0x008f, //
0x0090, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, //0x90
0x02dc, 0x2122, 0x009a, 0x203a, 0x0153, 0x009d, 0x009e, 0x0178, //
0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, //0xa0
0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, //
0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, //0xb0
0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, //
0x00c0, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x00c5, 0x00c6, 0x00c7, //0xc0
0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x0300, 0x00cd, 0x00ce, 0x00cf, //
0x0110, 0x00d1, 0x0309, 0x00d3, 0x00d4, 0x01a0, 0x00d6, 0x00d7, //0xd0
0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x01af, 0x0303, 0x00df, //
0x00e0, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x00e5, 0x00e6, 0x00e7, //0xe0
0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x0301, 0x00ed, 0x00ee, 0x00ef, //
0x0111, 0x00f1, 0x0323, 0x00f3, 0x00f4, 0x01a1, 0x00f6, 0x00f7, //0xf0
0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x01b0, 0x20ab, 0x00ff, //
};
static wchar_t cp1258_composed_table[][5] = {
{ 0x00c1, 0x00c0, 0x1ea2, 0x00c3, 0x1ea0 },
{ 0x00e1, 0x00e0, 0x1ea3, 0x00e3, 0x1ea1 },
{ 0x1eae, 0x1eb0, 0x1eb2, 0x1eb4, 0x1eb6 },
{ 0x1eaf, 0x1eb1, 0x1eb3, 0x1eb5, 0x1eb7 },
{ 0x1ea4, 0x1ea6, 0x1ea8, 0x1eaa, 0x1eac },
{ 0x1ea5, 0x1ea7, 0x1ea9, 0x1eab, 0x1ead },
{ 0x00c9, 0x00c8, 0x1eba, 0x1ebc, 0x1eb8 },
{ 0x00e9, 0x00e8, 0x1ebb, 0x1ebd, 0x1eb9 },
{ 0x1ebe, 0x1ec0, 0x1ec2, 0x1ec4, 0x1ec6 },
{ 0x1ebf, 0x1ec1, 0x1ec3, 0x1ec5, 0x1ec7 },
{ 0x00cd, 0x00cc, 0x1ec8, 0x0128, 0x1eca },
{ 0x00ed, 0x00ec, 0x1ec9, 0x0129, 0x1ecb },
{ 0x00d3, 0x00d2, 0x1ece, 0x00d5, 0x1ecc },
{ 0x00f3, 0x00f2, 0x1ecf, 0x00f5, 0x1ecd },
{ 0x1ed0, 0x1ed2, 0x1ed4, 0x1ed6, 0x1ed8 },
{ 0x1ed1, 0x1ed3, 0x1ed5, 0x1ed7, 0x1ed9 },
{ 0x1eda, 0x1edc, 0x1ede, 0x1ee0, 0x1ee2 },
{ 0x1edb, 0x1edd, 0x1edf, 0x1ee1, 0x1ee3 },
{ 0x00da, 0x00d9, 0x1ee6, 0x0168, 0x1ee4 },
{ 0x00fa, 0x00f9, 0x1ee7, 0x0169, 0x1ee5 },
{ 0x1ee8, 0x1eea, 0x1eec, 0x1eee, 0x1ef0 },
{ 0x1ee9, 0x1eeb, 0x1eed, 0x1eef, 0x1ef1 },
{ 0x00dd, 0x1ef2, 0x1ef6, 0x1ef8, 0x1ef4 },
{ 0x00fd, 0x1ef3, 0x1ef7, 0x1ef9, 0x1ef5 },
};
static bool IsTone(wchar_t tone)
{
switch(tone)
{
case 0x0300:
case 0x0301:
case 0x0309:
case 0x0303:
case 0x0323:
return true;
default:
return false;
}
}
static wchar_t ComposeTone(wchar_t prev, wchar_t tone)
{
int col, row;
switch(tone)
{
case 0x0301: col = 0; break;
case 0x0300: col = 1; break;
case 0x0309: col = 2; break;
case 0x0303: col = 3; break;
case 0x0323: col = 4; break;
default:
return prev;
}
switch(prev)
{
case 0x0041: row = 0; break;
case 0x0061: row = 1; break;
case 0x0102: row = 2; break;
case 0x0103: row = 3; break;
case 0x00C2: row = 4; break;
case 0x00E2: row = 5; break;
case 0x0045: row = 6; break;
case 0x0065: row = 7; break;
case 0x00CA: row = 8; break;
case 0x00EA: row = 9; break;
case 0x0049: row = 10; break;
case 0x0069: row = 11; break;
case 0x004F: row = 12; break;
case 0x006F: row = 13; break;
case 0x00D4: row = 14; break;
case 0x00F4: row = 15; break;
case 0x01A0: row = 16; break;
case 0x01A1: row = 17; break;
case 0x0055: row = 18; break;
case 0x0075: row = 19; break;
case 0x01AF: row = 20; break;
case 0x01B0: row = 21; break;
case 0x0059: row = 22; break;
case 0x0079: row = 23; break;
default:
return prev;
}
return cp1258_composed_table[row][col];
}
int EL_String_Decode_Vietnamese(const char* multi, int multiLen, wchar_t* wide, int wideLen)
{
if(multiLen < 0)
multiLen = (int)strlen(multi) + 1;
int src = 0;
int dest = 0;
if(multiLen > 0)
{
/* 첫글자는 무조건 변경 */
wchar_t prev = cp1258_to_unicode[(BYTE)multi[src++]];
while(src < multiLen)
{
wchar_t unicode = cp1258_to_unicode[(BYTE)multi[src]];
/* 다음 문자가 Tone 인가? */
if(IsTone(unicode))
{
/* 앞의 문자와 합하자. */
prev = ComposeTone(prev, unicode);
}
else
{
/* 일반 문자가 왔다. 앞 문자를 변환 */
if(dest < wideLen)
wide[dest++] = prev;
prev = unicode;
}
++src;
}
if(dest < wideLen)
wide[dest++] = prev;
}
return dest;
}
static bool DecomposeLetter(wchar_t input, char* letter)
{
switch(input)
{
case 0x00c1: // L'Á'
case 0x00c0: // L'À'
case 0x1ea2: // L'Ả'
case 0x00c3: // L'Ã'
case 0x1ea0: // L'Ạ'
*letter = 'A';
return true;
case 0x00e1: // L'á'
case 0x00e0: // L'à'
case 0x1ea3: // L'ả'
case 0x00e3: // L'ã'
case 0x1ea1: // L'ạ'
*letter = 'a';
return true;
case 0x1eae: // L'Ắ'
case 0x1eb0: // L'Ằ'
case 0x1eb2: // L'Ẳ'
case 0x1eb4: // L'Ẵ'
case 0x1eb6: // L'Ặ'
*letter = (char)0xc3;
return true;
case 0x1eaf: // L'ắ'
case 0x1eb1: // L'ằ'
case 0x1eb3: // L'ẳ'
case 0x1eb5: // L'ẵ'
case 0x1eb7: // L'ặ'
*letter = (char)0xe3;
return true;
case 0x1ea4: // L'Ấ'
case 0x1ea6: // L'Ầ'
case 0x1ea8: // L'Ẩ'
case 0x1eaa: // L'Ẫ'
case 0x1eac: // L'Ậ'
*letter = (char)0xc2;
return true;
case 0x1ea5: // L'ấ'
case 0x1ea7: // L'ầ'
case 0x1ea9: // L'ẩ'
case 0x1eab: // L'ẫ'
case 0x1ead: // L'ậ'
*letter = (char)0xe2;
return true;
case 0x00c9: // L'É'
case 0x00c8: // L'È'
case 0x1eba: // L'Ẻ'
case 0x1ebc: // L'Ẽ'
case 0x1eb8: // L'Ẹ'
*letter = (char)'E';
return true;
case 0x00e9: // L'é'
case 0x00e8: // L'è'
case 0x1ebb: // L'ẻ'
case 0x1ebd: // L'ẽ'
case 0x1eb9: // L'ẹ'
*letter = (char)'e';
return true;
case 0x1ebe: // L'Ế'
case 0x1ec0: // L'Ề'
case 0x1ec2: // L'Ể'
case 0x1ec4: // L'Ễ'
case 0x1ec6: // L'Ệ'
*letter = (char)0xca;
return true;
case 0x1ebf: // L'ế'
case 0x1ec1: // L'ề'
case 0x1ec3: // L'ể'
case 0x1ec5: // L'ễ'
case 0x1ec7: // L'ệ'
*letter = (char)0xea;
return true;
case 0x00cd: // L'Í'
case 0x00cc: // L'Ì'
case 0x1ec8: // L'Ỉ'
case 0x0128: // L'Ĩ'
case 0x1eca: // L'Ị'
*letter = (char)'I';
return true;
case 0x00ed: // L'í'
case 0x00ec: // L'ì'
case 0x1ec9: // L'ỉ'
case 0x0129: // L'ĩ'
case 0x1ecb: // L'ị'
*letter = (char)'i';
return true;
case 0x00d3: // L'Ó'
case 0x00d2: // L'Ò'
case 0x1ece: // L'Ỏ'
case 0x00d5: // L'Õ'
case 0x1ecc: // L'Ọ'
*letter = (char)'O';
return true;
case 0x00f3: // L'ó'
case 0x00f2: // L'ò'
case 0x1ecf: // L'ỏ'
case 0x00f5: // L'õ'
case 0x1ecd: // L'ọ'
*letter = (char)'o';
return true;
case 0x1ed0: // L'Ố'
case 0x1ed2: // L'Ồ'
case 0x1ed4: // L'Ổ'
case 0x1ed6: // L'Ỗ'
case 0x1ed8: // L'Ộ'
*letter = (char)0xd4;
return true;
case 0x1ed1: // L'ố'
case 0x1ed3: // L'ồ'
case 0x1ed5: // L'ổ'
case 0x1ed7: // L'ỗ'
case 0x1ed9: // L'ộ'
*letter = (char)0xf4;
return true;
case 0x1eda: // L'Ớ'
case 0x1edc: // L'Ờ'
case 0x1ede: // L'Ở'
case 0x1ee0: // L'Ỡ'
case 0x1ee2: // L'Ợ'
*letter = (char)0xd5;
return true;
case 0x1edb: // L'ớ'
case 0x1edd: // L'ờ'
case 0x1edf: // L'ở'
case 0x1ee1: // L'ỡ'
case 0x1ee3: // L'ợ'
*letter = (char)0xf5;
return true;
case 0x00da: // L'Ú'
case 0x00d9: // L'Ù'
case 0x1ee6: // L'Ủ'
case 0x0168: // L'Ũ'
case 0x1ee4: // L'Ụ'
*letter = (char)'U';
return true;
case 0x00fa: // L'ú'
case 0x00f9: // L'ù'
case 0x1ee7: // L'ủ'
case 0x0169: // L'ũ'
case 0x1ee5: // L'ụ'
*letter = (char)'u';
return true;
case 0x1ee8: // L'Ứ'
case 0x1eea: // L'Ừ'
case 0x1eec: // L'Ử'
case 0x1eee: // L'Ữ'
case 0x1ef0: // L'Ự'
*letter = (char)0xdd;
return true;
case 0x1ee9: // L'ứ'
case 0x1eeb: // L'ừ'
case 0x1eed: // L'ử'
case 0x1eef: // L'ữ'
case 0x1ef1: // L'ự'
*letter = (char)0xfd;
return true;
case 0x1ef2: // L'Ỳ'
case 0x00dd: // L'Ý'
case 0x1ef6: // L'Ỷ'
case 0x1ef8: // L'Ỹ'
case 0x1ef4: // L'Ỵ'
*letter = (char)'Y';
return true;
case 0x1ef3: // L'ỳ'
case 0x00fd: // L'ý'
case 0x1ef7: // L'ỷ'
case 0x1ef9: // L'ỹ'
case 0x1ef5: // L'ỵ'
*letter = (char)'y';
return true;
case 0x0102: // L'Ă'
*letter = (char)0xc3;
return true;
case 0x0103: // L'ă'
*letter = (char)0xe3;
return true;
case 0x0110: // L'Đ'
*letter = (char)0xd0;
return true;
case 0x0111: // L'đ'
*letter = (char)0xf0;
return true;
case 0x01a0: // L'Ơ'
*letter = (char)0xd5;
return true;
case 0x01a1: // L'ơ'
*letter = (char)0xf5;
return true;
case 0x01af: // L'Ư'
*letter = (char)0xdd;
return true;
case 0x01b0: // L'ư'
*letter = (char)0xfd;
return true;
case 0x20ab: // L'₫'
*letter = (char)0xfe;
return true;
case 0x201c: // L'“'
*letter = (char)'"';
return true;
case 0x201d: // L'”'
*letter = (char)'"';
return true;
}
if(input < 256)
{
*letter = (char)input;
return true;
}
return false;
}
static bool DecomposeTone(wchar_t input, char* tone)
{
switch(input)
{
case 0x00c1: // L'Á'
case 0x00e1: // L'á'
case 0x1eae: // L'Ắ'
case 0x1eaf: // L'ắ'
case 0x1ea4: // L'Ấ'
case 0x1ea5: // L'ấ'
case 0x00c9: // L'É'
case 0x00e9: // L'é'
case 0x1ebe: // L'Ế'
case 0x1ebf: // L'ế'
case 0x00cd: // L'Í'
case 0x00ed: // L'í'
case 0x00d3: // L'Ó'
case 0x00f3: // L'ó'
case 0x1ed0: // L'Ố'
case 0x1ed1: // L'ố'
case 0x1eda: // L'Ớ'
case 0x1edb: // L'ớ'
case 0x00da: // L'Ú'
case 0x00fa: // L'ú'
case 0x1ee8: // L'Ứ'
case 0x1ee9: // L'ứ'
case 0x00dd: // L'Ý'
case 0x00fd: // L'ý'
*tone = (char)0xec;
return true;
case 0x00c0: // L'À'
case 0x00e0: // L'à'
case 0x1eb0: // L'Ằ'
case 0x1eb1: // L'ằ'
case 0x1ea6: // L'Ầ'
case 0x1ea7: // L'ầ'
case 0x00c8: // L'È'
case 0x00e8: // L'è'
case 0x1ec0: // L'Ề'
case 0x1ec1: // L'ề'
case 0x00cc: // L'Ì'
case 0x00ec: // L'ì'
case 0x00d2: // L'Ò'
case 0x00f2: // L'ò'
case 0x1ed2: // L'Ồ'
case 0x1ed3: // L'ồ'
case 0x1edc: // L'Ờ'
case 0x1edd: // L'ờ'
case 0x00d9: // L'Ù'
case 0x00f9: // L'ù'
case 0x1eea: // L'Ừ'
case 0x1eeb: // L'ừ'
case 0x1ef2: // L'Ỳ'
case 0x1ef3: // L'ỳ'
*tone = (char)0xcc;
return true;
case 0x1ea2: // L'Ả'
case 0x1ea3: // L'ả'
case 0x1eb2: // L'Ẳ'
case 0x1eb3: // L'ẳ'
case 0x1ea8: // L'Ẩ'
case 0x1ea9: // L'ẩ'
case 0x1eba: // L'Ẻ'
case 0x1ebb: // L'ẻ'
case 0x1ec2: // L'Ể'
case 0x1ec3: // L'ể'
case 0x1ec8: // L'Ỉ'
case 0x1ec9: // L'ỉ'
case 0x1ece: // L'Ỏ'
case 0x1ecf: // L'ỏ'
case 0x1ed4: // L'Ổ'
case 0x1ed5: // L'ổ'
case 0x1ede: // L'Ở'
case 0x1edf: // L'ở'
case 0x1ee6: // L'Ủ'
case 0x1ee7: // L'ủ'
case 0x1eec: // L'Ử'
case 0x1eed: // L'ử'
case 0x1ef6: // L'Ỷ'
case 0x1ef7: // L'ỷ'
*tone = (char)0xd2;
return true;
case 0x00c3: // L'Ã'
case 0x00e3: // L'ã'
case 0x1eb4: // L'Ẵ'
case 0x1eb5: // L'ẵ'
case 0x1eaa: // L'Ẫ'
case 0x1eab: // L'ẫ'
case 0x1ebc: // L'Ẽ'
case 0x1ebd: // L'ẽ'
case 0x1ec4: // L'Ễ'
case 0x1ec5: // L'ễ'
case 0x0128: // L'Ĩ'
case 0x0129: // L'ĩ'
case 0x00d5: // L'Õ'
case 0x00f5: // L'õ'
case 0x1ed6: // L'Ỗ'
case 0x1ed7: // L'ỗ'
case 0x1ee0: // L'Ỡ'
case 0x1ee1: // L'ỡ'
case 0x0169: // L'ũ'
case 0x0168: // L'Ũ'
case 0x1eee: // L'Ữ'
case 0x1eef: // L'ữ'
case 0x1ef8: // L'Ỹ'
case 0x1ef9: // L'ỹ'
*tone = (char)0xde;
return true;
case 0x1ea0: // L'Ạ'
case 0x1ea1: // L'ạ'
case 0x1eb6: // L'Ặ'
case 0x1eb7: // L'ặ'
case 0x1eac: // L'Ậ'
case 0x1ead: // L'ậ'
case 0x1eb8: // L'Ẹ'
case 0x1eb9: // L'ẹ'
case 0x1ec6: // L'Ệ'
case 0x1ec7: // L'ệ'
case 0x1eca: // L'Ị'
case 0x1ecb: // L'ị'
case 0x1ecc: // L'Ọ'
case 0x1ecd: // L'ọ'
case 0x1ed8: // L'Ộ'
case 0x1ed9: // L'ộ'
case 0x1ee2: // L'Ợ'
case 0x1ee3: // L'ợ'
case 0x1ee4: // L'Ụ'
case 0x1ee5: // L'ụ'
case 0x1ef0: // L'Ự'
case 0x1ef1: // L'ự'
case 0x1ef4: // L'Ỵ'
case 0x1ef5: // L'ỵ'
*tone = (char)0xf2;
return true;
}
return false;
}
int EL_String_Encode_Vietnamese(const wchar_t* wide, int wideLen, char* multi, int multiLen)
{
if(wideLen < 0)
wideLen = (int)wcslen(wide) + 1;
int src = 0;
int dest = 0;
if(wideLen > 0)
{
while(src < wideLen && dest < multiLen)
{
char letter;
if(DecomposeLetter(wide[src], &letter))
{
multi[dest++] = letter;
}
char tone;
if(DecomposeTone(wide[src], &tone) && dest < multiLen)
{
multi[dest++] = tone;
}
++src;
}
}
return dest;
}

View File

@ -0,0 +1,4 @@
#pragma once
int EL_String_Decode_Vietnamese(const char* multi, int multiLen, wchar_t* wide, int wideLen);
int EL_String_Encode_Vietnamese(const wchar_t* wide, int wideLen, char* multi, int multiLen);