Bumping manifests a=b2g-bump
[gecko.git] / xpcom / io / nsNativeCharsetUtils.h
blob5c1e670d5e98e696687a6f1f0330a173c1dce692
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef nsNativeCharsetUtils_h__
8 #define nsNativeCharsetUtils_h__
11 /*****************************************************************************\
12 * *
13 * **** NOTICE **** *
14 * *
15 * *** THESE ARE NOT GENERAL PURPOSE CONVERTERS *** *
16 * *
17 * NS_CopyNativeToUnicode / NS_CopyUnicodeToNative should only be used *
18 * for converting *FILENAMES* between native and unicode. They are not *
19 * designed or tested for general encoding converter use. *
20 * *
21 \*****************************************************************************/
23 /**
24 * thread-safe conversion routines that do not depend on uconv libraries.
26 nsresult NS_CopyNativeToUnicode(const nsACString& aInput, nsAString& aOutput);
27 nsresult NS_CopyUnicodeToNative(const nsAString& aInput, nsACString& aOutput);
30 * This function indicates whether the character encoding used in the file
31 * system (more exactly what's used for |GetNativeFoo| and |SetNativeFoo|
32 * of |nsIFile|) is UTF-8 or not. Knowing that helps us avoid an
33 * unncessary encoding conversion in some cases. For instance, to get the leaf
34 * name in UTF-8 out of nsIFile, we can just use |GetNativeLeafName| rather
35 * than using |GetLeafName| and converting the result to UTF-8 if the file
36 * system encoding is UTF-8.
37 * On Unix (but not on Mac OS X), it depends on the locale and is not known
38 * in advance (at the compilation time) so that this function needs to be
39 * a real function. On Mac OS X it's always UTF-8 while on Windows
40 * and other platforms (e.g. OS2), it's never UTF-8.
42 #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(ANDROID)
43 bool NS_IsNativeUTF8();
44 #else
45 inline bool
46 NS_IsNativeUTF8()
48 #if defined(XP_MACOSX) || defined(ANDROID)
49 return true;
50 #else
51 return false;
52 #endif
54 #endif
57 /**
58 * internal
60 void NS_StartupNativeCharsetUtils();
61 void NS_ShutdownNativeCharsetUtils();
63 #endif // nsNativeCharsetUtils_h__