sl@0: /*
sl@0: * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
sl@0: * All rights reserved.
sl@0: * This component and the accompanying materials are made available
sl@0: * under the terms of the License "Eclipse Public License v1.0"
sl@0: * which accompanies this distribution, and is available
sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: *
sl@0: * Initial Contributors:
sl@0: * Nokia Corporation - initial contribution.
sl@0: *
sl@0: * Contributors:
sl@0: *
sl@0: * Description: 
sl@0: *     A utility for providing Japanese Language-specific (UNICODE) functions.
sl@0: *
sl@0: *
sl@0: */
sl@0: 
sl@0: 
sl@0: #ifndef __JPLANGUTIL_H__
sl@0: #define __JPLANGUTIL_H__
sl@0: 
sl@0: // INCLUDES
sl@0: #include <e32std.h>
sl@0: 
sl@0: // CONSTANTS
sl@0: 
sl@0: // CLASS DECLARATION
sl@0: 
sl@0: /**
sl@0:  *  This is the only class provided buy the JPLangUtil Library,
sl@0:  *  and is intended for encapsulation only.
sl@0:  *  As such, it should not be instantiated.
sl@0:  *
sl@0:  *  @lib JPLangUtil.lib
sl@0:  *  @since 2.6
sl@0:  */
sl@0: class JPLangUtil
sl@0:     {
sl@0:     public: // Conversion API
sl@0: 
sl@0:         /**
sl@0:         * Converts all Half-width conformant text (including ASCII, Special
sl@0:         * Characters and Katakana) found in aUnicodeSource to their Full-width
sl@0:         * counterparts and places the resulting text into aUnicodeTarget.
sl@0:         *
sl@0:         * @param aUnicodeSource Descriptor that contains the text to be
sl@0:         *        converted.
sl@0:         * @param aUnicodeTarget The target descriptor for the converted text.
sl@0:         *
sl@0:         * @return Either a positive integer signifying the count of converted
sl@0:         *         characters, or the negative error code KErrToBig when the
sl@0:         *         target descriptor cannot hold all the converted text.
sl@0:         */
sl@0:         IMPORT_C static TInt ConvertHalfToFullWidth
sl@0:             (const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget );
sl@0: 
sl@0:         /**
sl@0:         * Converts all Full-width conformant text found in aUnicodeSource to
sl@0:         * their Half-width counterparts and places the resulting text into
sl@0:         * aUnicodeTarget. Only those characters with existing Half-width
sl@0:         * variants are converted. There will be a 2-for-1 conversion for each
sl@0:         * Full-width Voiced and Semi-voiced Katakana character.
sl@0:         *
sl@0:         * @param aUnicodeSource Descriptor that contains the text to be
sl@0:         *        converted.
sl@0:         * @param aUnicodeTarget The target descriptor for the converted text.
sl@0:         *
sl@0:         * @return Either a positive integer signifying the count of converted
sl@0:         *         characters, or the negative error code KErrToBig when the
sl@0:         *         target descriptor cannot hold all the converted text.
sl@0:         */
sl@0:         IMPORT_C static TInt ConvertFullToHalfWidth
sl@0:             ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget );
sl@0: 
sl@0:         /**
sl@0:         * Converts Half-width Katakana and Special Character text found in
sl@0:         * aUnicodeSource to their Full-width counterparts and places the
sl@0:         * resulting text into aUnicodeTarget.
sl@0:         *
sl@0:         * @param aUnicodeSource Descriptor that contains the text to be
sl@0:         *        converted.
sl@0:         * @param aUnicodeTarget The target descriptor for the converted text.
sl@0:         *
sl@0:         * @return Either a positive integer signifying the count of converted
sl@0:         *         characters, or the negative error code KErrToBig when the
sl@0:         *         target descriptor cannot hold all the converted text.
sl@0:         */
sl@0:         IMPORT_C static TInt ConvertHalfToFullWidthKatakana
sl@0:             ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget );
sl@0: 
sl@0:         /**
sl@0:         * Converts Full-width Katakana and Special Character text found in
sl@0:         * aUnicodeSource to their Half-width counterparts and places the
sl@0:         * resulting text into aUnicodeTarget. There will be a 2-for-1 conversion
sl@0:         * for each Full-width Voiced and Semi-voiced Katakana character.
sl@0:         *
sl@0:         * @param aUnicodeSource Descriptor that contains the text to be
sl@0:         *        converted.
sl@0:         * @param aUnicodeTarget The target descriptor for the converted text.
sl@0:         *
sl@0:         * @return Either a positive integer signifying the count of converted
sl@0:         *         characters, or the negative error code KErrToBig when the
sl@0:         *         target descriptor cannot hold all the converted text.
sl@0:         */
sl@0:         IMPORT_C static TInt ConvertFullToHalfWidthKatakana
sl@0:             ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget );
sl@0: 
sl@0:         /**
sl@0:         * Converts Full-width Hiragana and Special Character text found in
sl@0:         * aUnicodeSource to their Full-width counterparts and places the
sl@0:         * resulting text into aUnicodeTarget.
sl@0:         *
sl@0:         * @param aUnicodeSource Descriptor that contains the text to be
sl@0:         *        converted.
sl@0:         * @param aUnicodeTarget The target descriptor for the converted text.
sl@0:         *
sl@0:         * @return Either a positive integer signifying the count of converted
sl@0:         *         characters, or the negative error code KErrToBig when the
sl@0:         *         target descriptor cannot hold all the converted text.
sl@0:         */
sl@0:         IMPORT_C static TInt ConvertFullHiragnaToFullKatakana
sl@0:             ( const TDesC16& aUnicodeSource, TDes16& aUnicodeTarget );
sl@0: 
sl@0:     public: // Character Category Query API
sl@0: 
sl@0:         /**
sl@0:         * Returns ETrue if aUnicodeChar is Katakana.
sl@0:         * This includes both Full and Half-width Katakana.
sl@0:         *
sl@0:         * @param aUnicodeChar The unicode character to test.
sl@0:         *
sl@0:         * @return Etrue : aUnicodeChar is Katakana
sl@0:         */
sl@0:         IMPORT_C static TBool IsKatakana( const TText aUnicodeChar );
sl@0: 
sl@0:         /**
sl@0:         * Returns ETrue if aUnicodeChar is Hiragana.
sl@0:         * There are no Half-width Hiragana variants.
sl@0:         *
sl@0:         * @param aUnicodeChar The unicode character to test.
sl@0:         *
sl@0:         * @return Etrue : aUnicodeChar is Hiragana
sl@0:         */
sl@0:         IMPORT_C static TBool IsHiragana( const TText aUnicodeChar );
sl@0: 
sl@0:         /**
sl@0:         * Returns ETrue if aUnicodeChar is Kanji, or CJK ideographic
sl@0:         * All characters in the CJK ideographic range are Full-width.
sl@0:         *
sl@0:         * @param aUnicodeChar The unicode character to test.
sl@0:         *
sl@0:         * @return Etrue : aUnicodeChar is Kanji
sl@0:         */
sl@0:         IMPORT_C static TBool IsKanji( const TText aUnicodeChar );
sl@0: 
sl@0:         /**
sl@0:         * Returns ETrue if aUnicodeChar is Half-width according to
sl@0:         * the UNICODE definition of the term.
sl@0:         *
sl@0:         * @param aUnicodeChar The unicode character to test.
sl@0:         *
sl@0:         * @return Etrue : aUnicodeChar is Half-width
sl@0:         */
sl@0:         IMPORT_C static TBool IsHalfWidth( const TText aUnicodeChar );
sl@0: 
sl@0:         /**
sl@0:         * Returns ETrue if aUnicodeChar is Full-width.
sl@0:         * Essentially, all text that is not Half-width.
sl@0:         *
sl@0:         * @param aUnicodeChar The unicode character to test.
sl@0:         *
sl@0:         * @return Etrue : aUnicodeChar is Full-width
sl@0:         */
sl@0:         IMPORT_C static TBool IsFullWidth( const TText aUnicodeChar );
sl@0: 
sl@0:     };
sl@0: 
sl@0: #endif //  __JPLANGUTIL_H__
sl@0: 
sl@0: // End of file