xpcom/io/nsNativeCharsetUtils.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:40a0e4c37966
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #ifndef nsNativeCharsetUtils_h__
6 #define nsNativeCharsetUtils_h__
7
8
9 /*****************************************************************************\
10 * *
11 * **** NOTICE **** *
12 * *
13 * *** THESE ARE NOT GENERAL PURPOSE CONVERTERS *** *
14 * *
15 * NS_CopyNativeToUnicode / NS_CopyUnicodeToNative should only be used *
16 * for converting *FILENAMES* between native and unicode. They are not *
17 * designed or tested for general encoding converter use. *
18 * *
19 \*****************************************************************************/
20
21 /**
22 * thread-safe conversion routines that do not depend on uconv libraries.
23 */
24 nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString &output);
25 nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &output);
26
27 /*
28 * This function indicates whether the character encoding used in the file
29 * system (more exactly what's used for |GetNativeFoo| and |SetNativeFoo|
30 * of |nsIFile|) is UTF-8 or not. Knowing that helps us avoid an
31 * unncessary encoding conversion in some cases. For instance, to get the leaf
32 * name in UTF-8 out of nsIFile, we can just use |GetNativeLeafName| rather
33 * than using |GetLeafName| and converting the result to UTF-8 if the file
34 * system encoding is UTF-8.
35 * On Unix (but not on Mac OS X), it depends on the locale and is not known
36 * in advance (at the compilation time) so that this function needs to be
37 * a real function. On Mac OS X it's always UTF-8 while on Windows
38 * and other platforms (e.g. OS2), it's never UTF-8.
39 */
40 #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(ANDROID)
41 bool NS_IsNativeUTF8();
42 #else
43 inline bool NS_IsNativeUTF8()
44 {
45 #if defined(XP_MACOSX) || defined(ANDROID)
46 return true;
47 #else
48 return false;
49 #endif
50 }
51 #endif
52
53
54 /**
55 * internal
56 */
57 void NS_StartupNativeCharsetUtils();
58 void NS_ShutdownNativeCharsetUtils();
59
60 #endif // nsNativeCharsetUtils_h__

mercurial