2 * Copyright 2012-2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "MmsPluginDebug.h"
18 #include "MmsPluginMIME.h"
19 #include "MmsPluginCodec.h"
20 #include "MmsPluginTextConvert.h"
21 #include "MmsPluginUtil.h"
23 const char *MmsPluginTextConvertGetCharSet(int MIBEnum)
25 const char * result_str = NULL;
27 result_str = MmsGetTextByCode(MmsCodeCharSet, (unsigned short int)MIBEnum);
28 MSG_DEBUG("[MIBEnum = %d, Charset = %s]", MIBEnum, result_str);
33 bool MmsPluginTextConvert(const char *pToCodeSet, const char *pFromCodeset, const char *pSrc, int srcLen, char **ppDest, int *pDestLen)
37 gsize bytes_written = 0;
40 if (pToCodeSet == NULL || pFromCodeset == NULL) {
41 MSG_DEBUG("Error input parameter Codeset to = %s, from = %s", pToCodeSet, pFromCodeset);
45 MSG_DEBUG("Codeset to = %s, from = %s", pToCodeSet, pFromCodeset);
47 if (pSrc == NULL || ppDest == NULL || pDestLen == NULL) {
48 MSG_DEBUG("Error input parameter pSrc = %p, ppDest = %p, pDestLen = %p", pSrc, ppDest, pDestLen);
52 pDest = g_convert (pSrc, srcLen,
53 pToCodeSet, pFromCodeset,
54 &bytes_read, &bytes_written,
58 printf("Error in g_convert, GError = %d:%s, pSrc = %s\n", error->code, error->message, pSrc);
62 if (pDest == NULL || bytes_written == 0 || bytes_read == 0) {
63 printf("Error in g_convert, pDest = %s, bytes_written = %d, bytes_read = %d\n", pDest, bytes_written, bytes_read);
68 *pDestLen = bytes_written;