Update contrib.
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 // Contains the source for the wcrtomb API implementation.
31 #if (defined(__SYMBIAN32__) && (defined(__WINSCW__) || defined(__WINS__)))
32 #include "libc_wsd_defs.h"
37 GET_STATIC_VAR_FROM_TLS(wcrtomb_mbs, mbstate_t)
38 #define mbs (*GET_WSD_VAR_NAME(wcrtomb_mbs, s)())
41 //-----------------------------------------------------------------------------
42 //Function Name : size_t wcrtomb (char * mbchar, wchar_t wc, mbstate_t* ps)
43 //Description : Converts a wide character to a multibyte character
44 //Return Value : return If mbchar is null, the return value is true (non-zero)
45 //if multibyte characters have state-dependent encodings, or false (zero)
47 //-----------------------------------------------------------------------------
50 EXPORT_C size_t wcrtomb (char * mbchar, wchar_t wc, mbstate_t* ps)
59 mbstate_t *state = NULL;
70 //deal with the special null character case
76 memset(state,0,sizeof(state));
77 state->__count = _EUTF16InitialState;
82 //return value of 0 is possible if the first half of a surrogate pair seen
83 //crash is possible if mbchar is not at least MB_CUR_MAX bytes long
84 return _Utf16ToUtf8(mbchar,wc, state,MB_CUR_MAX);
86 //calling with a null dest string is used to initialise shift state
87 //effect is exactly as if internal dst buffer was used.
88 //therefore we always return 1.
93 memset(state,0,sizeof(state));
94 state->__count = _EUTF16InitialState;