equal
deleted
inserted
replaced
|
1 /* |
|
2 * Copyright (c) 2008 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 "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: Common utils needed for file extended |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "logger.h" |
|
19 #include "fileextendedcommon.h" |
|
20 |
|
21 using namespace std; |
|
22 using namespace java::fileutility; |
|
23 |
|
24 wstring FileUtil::jstringToWstring(JNIEnv* env, const jstring& jStr) |
|
25 { |
|
26 #ifdef __SYMBIAN32__ |
|
27 jboolean iscopy = NULL; |
|
28 const jchar* jChr = env->GetStringChars(jStr, &iscopy); |
|
29 std::wstring wKey((wchar_t*)jChr); |
|
30 env->ReleaseStringChars(jStr, jChr); |
|
31 return wKey; |
|
32 #else |
|
33 // In Linux, size of jchar is 2 and wchar_t is 4 bytes |
|
34 // need to compensate that. |
|
35 const jchar* jChr = env->GetStringChars(jStr, NULL); |
|
36 int length = env->GetStringLength(jStr); |
|
37 wchar_t *wchr = new wchar_t[length + 1]; |
|
38 |
|
39 int i = 0; |
|
40 for (i = 0; i < length; i++) |
|
41 { |
|
42 wchr[i] = jChr[i]; |
|
43 } |
|
44 |
|
45 wchr[i] = L'\0'; |
|
46 std::wstring ret(wchr); |
|
47 env->ReleaseStringChars(jStr, jChr); |
|
48 delete[] wchr; |
|
49 return ret; |
|
50 #endif |
|
51 } |