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