diff options
author | Winfried Donkers <winfrieddonkers@libreoffice.org> | 2018-02-01 15:39:56 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2018-02-02 16:09:18 +0100 |
commit | 6c79c9053e3090df09fc2c0a24f1fec26ac8bf02 (patch) | |
tree | 93f0f9b8e523708c8b06929a8dd673b6c4fe3716 /i18nutil | |
parent | e6ced1496da9580cf885cce1a2fc9f67528c3a0e (diff) |
Clean up of dirty hack.
Follow up of tdf#103550. The conversion from half to full width characters and vice versa happens per character according to a table. There is no need to have a separate table with exceptions to the general rule.
Change-Id: Id611d1d6074cb2489fb0254d8ba9a83d7c26065f
Reviewed-on: https://gerrit.libreoffice.org/49102
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'i18nutil')
-rw-r--r-- | i18nutil/source/utility/widthfolding.cxx | 45 | ||||
-rw-r--r-- | i18nutil/source/utility/widthfolding_data.h | 23 |
2 files changed, 5 insertions, 63 deletions
diff --git a/i18nutil/source/utility/widthfolding.cxx b/i18nutil/source/utility/widthfolding.cxx index a7e8dd05c285..8db7524235e2 100644 --- a/i18nutil/source/utility/widthfolding.cxx +++ b/i18nutil/source/utility/widthfolding.cxx @@ -214,27 +214,6 @@ oneToOneMapping& widthfolding::getfull2halfTableForASC() static oneToOneMappingWithFlag table(full2half, sizeof(full2half), FULL2HALF_ASC_FUNCTION); table.makeIndex(); - // bluedwarf: dirty hack! - // There is an exception. Additional conversion is required following: - // 0xFFE5 (FULLWIDTH YEN SIGN) --> 0x005C (REVERSE SOLIDUS) - // - // See the following page for detail: - // http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions - for( int i = 0; i < int(SAL_N_ELEMENTS(full2halfASCException)); i++ ) - { - const int high = (full2halfASCException[i].first >> 8) & 0xFF; - const int low = (full2halfASCException[i].first) & 0xFF; - - if( !table.mpIndex[high] ) - { - table.mpIndex[high] = new UnicodePairWithFlag*[256]; - - for( int j = 0; j < 256; j++ ) - table.mpIndex[high][j] = nullptr; - } - table.mpIndex[high][low] = &full2halfASCException[i]; - } - return table; } @@ -243,30 +222,6 @@ oneToOneMapping& widthfolding::gethalf2fullTableForJIS() static oneToOneMappingWithFlag table(half2full, sizeof(half2full), HALF2FULL_JIS_FUNCTION); table.makeIndex(); - // bluedwarf: dirty hack! - // There are some exceptions. Additional conversion are required following: - // 0x0022 (QUOTATION MARK) --> 0x201D (RIGHT DOUBLE QUOTATION MARK) - // 0x0027 (APOSTROPHE) --> 0x2019 (RIGHT SINGLE QUOTATION MARK) - // 0x005C (REVERSE SOLIDUS) --> 0xFFE5 (FULLWIDTH YEN SIGN) - // 0x0060 (GRAVE ACCENT) --> 0x2018 (LEFT SINGLE QUOTATION MARK) - // - // See the following page for detail: - // http://wiki.openoffice.org/wiki/Calc/Features/JIS_and_ASC_functions - for( int i = 0; i < int(SAL_N_ELEMENTS(half2fullJISException)); i++ ) - { - const int high = (half2fullJISException[i].first >> 8) & 0xFF; - const int low = (half2fullJISException[i].first) & 0xFF; - - if( !table.mpIndex[high] ) - { - table.mpIndex[high] = new UnicodePairWithFlag*[256]; - - for( int j = 0; j < 256; j++ ) - table.mpIndex[high][j] = nullptr; - } - table.mpIndex[high][low] = &half2fullJISException[i]; - } - return table; } diff --git a/i18nutil/source/utility/widthfolding_data.h b/i18nutil/source/utility/widthfolding_data.h index 999ca82734b1..b1c0e2c00c57 100644 --- a/i18nutil/source/utility/widthfolding_data.h +++ b/i18nutil/source/utility/widthfolding_data.h @@ -481,17 +481,11 @@ UnicodePairWithFlag full2half[] = { { 0xFFE3, 0x00AF, FULL2HALF_NORMAL }, // FULLWIDTH MACRON --> MACRON { 0xFFE4, 0x00A6, FULL2HALF_NORMAL }, // FULLWIDTH BROKEN BAR --> BROKEN BAR { 0xFFE5, 0x00A5, FULL2HALF_NORMAL }, // FULLWIDTH YEN SIGN --> YEN SIGN + { 0xFFE5, 0x005C, FULL2HALF_ASC_FUNCTION }, // FULLWIDTH YEN SIGN --> REVERSE SOLIDUS, exceptional conversion { 0xFFE6, 0x20A9, FULL2HALF_NORMAL }, // FULLWIDTH WON SIGN --> WON SIGN }; /* - Exceptional conversion table for ASC function -*/ -UnicodePairWithFlag full2halfASCException[] = { - { 0xFFE5, 0x005C, FULL2HALF_ASC_FUNCTION } // FULLWIDTH YEN SIGN --> REVERSE SOLIDUS - }; - -/* Unicode Normalization Forms http://www.unicode.org/unicode/reports/tr15/index.html http://www.w3.org/International/charlint/ @@ -708,11 +702,13 @@ UnicodePairWithFlag half2full[] = { { 0x0020, 0x3000, HALF2FULL_NORMAL }, // SPACE --> IDEOGRAPHIC SPACE { 0x0021, 0xFF01, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // EXCLAMATION MARK --> FULLWIDTH EXCLAMATION MARK { 0x0022, 0xFF02, HALF2FULL_NORMAL }, // QUOTATION MARK --> FULLWIDTH QUOTATION MARK + { 0x0022, 0x201D, HALF2FULL_JIS_FUNCTION }, // QUOTATION MARK --> RIGHT DOUBLE QUOTATION MARK, exceptional conversion { 0x0023, 0xFF03, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // NUMBER SIGN --> FULLWIDTH NUMBER SIGN { 0x0024, 0xFF04, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // DOLLAR SIGN --> FULLWIDTH DOLLAR SIGN { 0x0025, 0xFF05, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // PERCENT SIGN --> FULLWIDTH PERCENT SIGN { 0x0026, 0xFF06, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // AMPERSAND --> FULLWIDTH AMPERSAND { 0x0027, 0xFF07, HALF2FULL_NORMAL }, // APOSTROPHE --> FULLWIDTH APOSTROPHE + { 0x0027, 0x2019, HALF2FULL_JIS_FUNCTION }, // APOSTROPHE --> RIGHT SINGLE QUOTATION MARK, exceptional conversion { 0x0028, 0xFF08, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // LEFT PARENTHESIS --> FULLWIDTH LEFT PARENTHESIS { 0x0029, 0xFF09, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // RIGHT PARENTHESIS --> FULLWIDTH RIGHT PARENTHESIS { 0x002A, 0xFF0A, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // ASTERISK --> FULLWIDTH ASTERISK @@ -766,10 +762,12 @@ UnicodePairWithFlag half2full[] = { { 0x005A, 0xFF3A, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // LATIN CAPITAL LETTER Z --> FULLWIDTH LATIN CAPITAL LETTER Z { 0x005B, 0xFF3B, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // LEFT SQUARE BRACKET --> FULLWIDTH LEFT SQUARE BRACKET { 0x005C, 0xFF3C, HALF2FULL_NORMAL }, // REVERSE SOLIDUS --> FULLWIDTH REVERSE SOLIDUS + { 0x005C, 0xFFE5, HALF2FULL_JIS_FUNCTION }, // REVERSE SOLIDUS --> FULLWIDTH YEN SIGN, exceptional conversion { 0x005D, 0xFF3D, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // RIGHT SQUARE BRACKET --> FULLWIDTH RIGHT SQUARE BRACKET { 0x005E, 0xFF3E, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // CIRCUMFLEX ACCENT --> FULLWIDTH CIRCUMFLEX ACCENT { 0x005F, 0xFF3F, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // LOW LINE --> FULLWIDTH LOW LINE { 0x0060, 0xFF40, HALF2FULL_NORMAL }, // GRAVE ACCENT --> FULLWIDTH GRAVE ACCENT + { 0x0060, 0x2018, HALF2FULL_JIS_FUNCTION }, // GRAVE ACCENT --> LEFT SINGLE QUOTATION MARK, exceptional conversion { 0x0061, 0xFF41, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // LATIN SMALL LETTER A --> FULLWIDTH LATIN SMALL LETTER A { 0x0062, 0xFF42, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // LATIN SMALL LETTER B --> FULLWIDTH LATIN SMALL LETTER B { 0x0063, 0xFF43, HALF2FULL_NORMAL | HALF2FULL_JIS_FUNCTION }, // LATIN SMALL LETTER C --> FULLWIDTH LATIN SMALL LETTER C @@ -936,17 +934,6 @@ UnicodePairWithFlag half2full[] = { { 0xFFEE, 0x25CB, HALF2FULL_NORMAL }, // HALFWIDTH WHITE CIRCLE --> WHITE CIRCLE }; -/* - Exceptional conversion table for JIS function -*/ -UnicodePairWithFlag half2fullJISException[] = { - { 0x0022, 0x201D, HALF2FULL_JIS_FUNCTION }, // QUOTATION MARK --> RIGHT DOUBLE QUOTATION MARK - { 0x0027, 0x2019, HALF2FULL_JIS_FUNCTION }, // APOSTROPHE --> RIGHT SINGLE QUOTATION MARK - { 0x005C, 0xFFE5, HALF2FULL_JIS_FUNCTION }, // REVERSE SOLIDUS --> FULLWIDTH YEN SIGN - { 0x0060, 0x2018, HALF2FULL_JIS_FUNCTION }, // GRAVE ACCENT --> LEFT SINGLE QUOTATION MARK - }; - - } #endif |