diff --git a/lib/libZRCola/include/zrcola/common.h b/lib/libZRCola/include/zrcola/common.h index 46b3188..639c7ec 100644 --- a/lib/libZRCola/include/zrcola/common.h +++ b/lib/libZRCola/include/zrcola/common.h @@ -44,7 +44,12 @@ /// /// Database IDs /// -#define ZRCOLA_DB_ID (*(ZRCola::recordid_t*)"ZRC") +#define ZRCOLA_DB_ID (*(ZRCola::recordid_t*)"ZRC") + +/// +/// Unknown language ID +/// +#define ZRCOLA_LANG_VOID " " namespace ZRCola { diff --git a/lib/libZRCola/include/zrcola/translate.h b/lib/libZRCola/include/zrcola/translate.h index f0e3b35..b6f5df6 100644 --- a/lib/libZRCola/include/zrcola/translate.h +++ b/lib/libZRCola/include/zrcola/translate.h @@ -20,6 +20,7 @@ #pragma once #include "common.h" +#include "language.h" #include #include @@ -216,7 +217,22 @@ namespace ZRCola { /// \param[out] output Output string (UTF-16) /// \param[out] map The vector of source to destination index mappings (optional) /// - void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector* map = NULL) const; + inline void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector* map = NULL) const + { + Decompose(input, inputMax, NULL, ZRCOLA_LANG_VOID, output, map); + } + + /// + /// Decomposes string according ommiting language specific characters + /// + /// \param[in] input Input string (UTF-16) + /// \param[in] inputMax Length of the input string in characters. Can be (size_t)-1 if \p input is zero terminated. + /// \param[in] lc_db Language character database + /// \param[in] lang Language ID + /// \param[out] output Output string (UTF-16) + /// \param[out] map The vector of source to destination index mappings (optional) + /// + void Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_opt_ const langchar_db *lc_db, _In_opt_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector* map = NULL) const; }; diff --git a/lib/libZRCola/src/normalize.cpp b/lib/libZRCola/src/normalize.cpp index 102197c..0204b3a 100644 --- a/lib/libZRCola/src/normalize.cpp +++ b/lib/libZRCola/src/normalize.cpp @@ -20,6 +20,6 @@ #include "stdafx.h" -void ZRCOLA_API ZRCola::Normalize(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector* map) +void ZRCola::Normalize(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector* map) { } diff --git a/lib/libZRCola/src/translate.cpp b/lib/libZRCola/src/translate.cpp index d43579f..82830cb 100644 --- a/lib/libZRCola/src/translate.cpp +++ b/lib/libZRCola/src/translate.cpp @@ -102,7 +102,7 @@ void ZRCola::translation_db::Compose(_In_z_count_(inputMax) const wchar_t* input } -void ZRCOLA_API ZRCola::translation_db::Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _Out_ std::wstring &output, _Out_opt_ std::vector* map) const +void ZRCola::translation_db::Decompose(_In_z_count_(inputMax) const wchar_t* input, _In_ size_t inputMax, _In_ const langchar_db *lc_db, _In_ langid_t lang, _Out_ std::wstring &output, _Out_opt_ std::vector* map) const { assert(input || inputMax == 0); @@ -131,7 +131,7 @@ void ZRCOLA_API ZRCola::translation_db::Decompose(_In_z_count_(inputMax) const w else if (decompSrc < c) l = m + 1; else { // Character found. - if (trans.str_len && trans.str[0] != L'#') { + if (trans.str_len && trans.str[0] != L'#' && (!lc_db || !lc_db->IsLocalCharacter(c, lang))) { // Append decomposed sequence. output.append(trans.str, trans.str_len); i++;