sl@0: // Copyright (c) 2005-2009 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 "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: // Name : wcwidth.cpp sl@0: // Part of : MRT LIBC sl@0: // Contains the source for wcwidth API implementation. sl@0: // Version : sl@0: // sl@0: sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: #ifdef __cplusplus sl@0: extern "C" { sl@0: #endif sl@0: sl@0: EXPORT_C int sl@0: wcwidth(wchar_t wc) sl@0: { sl@0: int rVal,result = 0; sl@0: TChar::TCjkWidth rWid; sl@0: sl@0: //check for end of string sl@0: if(wc == L'\0') sl@0: { sl@0: return (result); sl@0: } sl@0: sl@0: //check if the character is printable sl@0: rVal = iswprint((wint_t)wc); sl@0: sl@0: //if printable sl@0: if(rVal) sl@0: { sl@0: rWid = (TChar::TCjkWidth)TChar((TUint)wc).GetCjkWidth(); sl@0: if(rWid == TChar::ENarrow) sl@0: { sl@0: result = TChar::EHalfWidth; sl@0: } sl@0: if(rWid == TChar::EWide) sl@0: { sl@0: result = TChar::EFullWidth; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: result = -1;//if the character is not printable sl@0: } sl@0: sl@0: return (result); sl@0: } sl@0: sl@0: #ifdef __cplusplus sl@0: } sl@0: #endif sl@0: