textandlocutils/jplangutil/inc/jplangutil.h
branchRCL_3
changeset 54 748ec5531811
equal deleted inserted replaced
36:f902e87c146f 54:748ec5531811
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *     A utility for providing Japanese Language-specific (UNICODE) functions.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #ifndef __JPLANGUTIL_H__
       
    22 #define __JPLANGUTIL_H__
       
    23 
       
    24 // INCLUDES
       
    25 #include <e32std.h>
       
    26 
       
    27 // CONSTANTS
       
    28 
       
    29 // CLASS DECLARATION
       
    30 
       
    31 /**
       
    32  *  This is the only class provided buy the JPLangUtil Library,
       
    33  *  and is intended for encapsulation only.
       
    34  *  As such, it should not be instantiated.
       
    35  *
       
    36  *  @lib JPLangUtil.lib
       
    37  *  @since 2.6
       
    38  */
       
    39 class JPLangUtil
       
    40     {
       
    41     public: // Conversion API
       
    42 
       
    43         /**
       
    44         * Converts all Half-width conformant text (including ASCII, Special
       
    45         * Characters and Katakana) found in aUnicodeSource to their Full-width
       
    46         * counterparts and places the resulting text into aUnicodeTarget.
       
    47         *
       
    48         * @param aUnicodeSource Descriptor that contains the text to be
       
    49         *        converted.
       
    50         * @param aUnicodeTarget The target descriptor for the converted text.
       
    51         *
       
    52         * @return Either a positive integer signifying the count of converted
       
    53         *         characters, or the negative error code KErrToBig when the
       
    54         *         target descriptor cannot hold all the converted text.
       
    55         */
       
    56         IMPORT_C static TInt ConvertHalfToFullWidth
       
    57             (const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget );
       
    58 
       
    59         /**
       
    60         * Converts all Full-width conformant text found in aUnicodeSource to
       
    61         * their Half-width counterparts and places the resulting text into
       
    62         * aUnicodeTarget. Only those characters with existing Half-width
       
    63         * variants are converted. There will be a 2-for-1 conversion for each
       
    64         * Full-width Voiced and Semi-voiced Katakana character.
       
    65         *
       
    66         * @param aUnicodeSource Descriptor that contains the text to be
       
    67         *        converted.
       
    68         * @param aUnicodeTarget The target descriptor for the converted text.
       
    69         *
       
    70         * @return Either a positive integer signifying the count of converted
       
    71         *         characters, or the negative error code KErrToBig when the
       
    72         *         target descriptor cannot hold all the converted text.
       
    73         */
       
    74         IMPORT_C static TInt ConvertFullToHalfWidth
       
    75             ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget );
       
    76 
       
    77         /**
       
    78         * Converts Half-width Katakana and Special Character text found in
       
    79         * aUnicodeSource to their Full-width counterparts and places the
       
    80         * resulting text into aUnicodeTarget.
       
    81         *
       
    82         * @param aUnicodeSource Descriptor that contains the text to be
       
    83         *        converted.
       
    84         * @param aUnicodeTarget The target descriptor for the converted text.
       
    85         *
       
    86         * @return Either a positive integer signifying the count of converted
       
    87         *         characters, or the negative error code KErrToBig when the
       
    88         *         target descriptor cannot hold all the converted text.
       
    89         */
       
    90         IMPORT_C static TInt ConvertHalfToFullWidthKatakana
       
    91             ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget );
       
    92 
       
    93         /**
       
    94         * Converts Full-width Katakana and Special Character text found in
       
    95         * aUnicodeSource to their Half-width counterparts and places the
       
    96         * resulting text into aUnicodeTarget. There will be a 2-for-1 conversion
       
    97         * for each Full-width Voiced and Semi-voiced Katakana character.
       
    98         *
       
    99         * @param aUnicodeSource Descriptor that contains the text to be
       
   100         *        converted.
       
   101         * @param aUnicodeTarget The target descriptor for the converted text.
       
   102         *
       
   103         * @return Either a positive integer signifying the count of converted
       
   104         *         characters, or the negative error code KErrToBig when the
       
   105         *         target descriptor cannot hold all the converted text.
       
   106         */
       
   107         IMPORT_C static TInt ConvertFullToHalfWidthKatakana
       
   108             ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget );
       
   109 
       
   110         /**
       
   111         * Converts Full-width Hiragana and Special Character text found in
       
   112         * aUnicodeSource to their Full-width counterparts and places the
       
   113         * resulting text into aUnicodeTarget.
       
   114         *
       
   115         * @param aUnicodeSource Descriptor that contains the text to be
       
   116         *        converted.
       
   117         * @param aUnicodeTarget The target descriptor for the converted text.
       
   118         *
       
   119         * @return Either a positive integer signifying the count of converted
       
   120         *         characters, or the negative error code KErrToBig when the
       
   121         *         target descriptor cannot hold all the converted text.
       
   122         */
       
   123         IMPORT_C static TInt ConvertFullHiragnaToFullKatakana
       
   124             ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget );
       
   125 
       
   126     public: // Character Category Query API
       
   127 
       
   128         /**
       
   129         * Returns ETrue if aUnicodeChar is Katakana.
       
   130         * This includes both Full and Half-width Katakana.
       
   131         *
       
   132         * @param aUnicodeChar The unicode character to test.
       
   133         *
       
   134         * @return Etrue : aUnicodeChar is Katakana
       
   135         */
       
   136         IMPORT_C static TBool IsKatakana( const TText aUnicodeChar );
       
   137 
       
   138         /**
       
   139         * Returns ETrue if aUnicodeChar is Hiragana.
       
   140         * There are no Half-width Hiragana variants.
       
   141         *
       
   142         * @param aUnicodeChar The unicode character to test.
       
   143         *
       
   144         * @return Etrue : aUnicodeChar is Hiragana
       
   145         */
       
   146         IMPORT_C static TBool IsHiragana( const TText aUnicodeChar );
       
   147 
       
   148         /**
       
   149         * Returns ETrue if aUnicodeChar is Kanji, or CJK ideographic
       
   150         * All characters in the CJK ideographic range are Full-width.
       
   151         *
       
   152         * @param aUnicodeChar The unicode character to test.
       
   153         *
       
   154         * @return Etrue : aUnicodeChar is Kanji
       
   155         */
       
   156         IMPORT_C static TBool IsKanji( const TText aUnicodeChar );
       
   157 
       
   158         /**
       
   159         * Returns ETrue if aUnicodeChar is Half-width according to
       
   160         * the UNICODE definition of the term.
       
   161         *
       
   162         * @param aUnicodeChar The unicode character to test.
       
   163         *
       
   164         * @return Etrue : aUnicodeChar is Half-width
       
   165         */
       
   166         IMPORT_C static TBool IsHalfWidth( const TText aUnicodeChar );
       
   167 
       
   168         /**
       
   169         * Returns ETrue if aUnicodeChar is Full-width.
       
   170         * Essentially, all text that is not Half-width.
       
   171         *
       
   172         * @param aUnicodeChar The unicode character to test.
       
   173         *
       
   174         * @return Etrue : aUnicodeChar is Full-width
       
   175         */
       
   176         IMPORT_C static TBool IsFullWidth( const TText aUnicodeChar );
       
   177 
       
   178     };
       
   179 
       
   180 #endif //  __JPLANGUTIL_H__
       
   181 
       
   182 // End of file