michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef nsNativeCharsetUtils_h__ michael@0: #define nsNativeCharsetUtils_h__ michael@0: michael@0: michael@0: /*****************************************************************************\ michael@0: * * michael@0: * **** NOTICE **** * michael@0: * * michael@0: * *** THESE ARE NOT GENERAL PURPOSE CONVERTERS *** * michael@0: * * michael@0: * NS_CopyNativeToUnicode / NS_CopyUnicodeToNative should only be used * michael@0: * for converting *FILENAMES* between native and unicode. They are not * michael@0: * designed or tested for general encoding converter use. * michael@0: * * michael@0: \*****************************************************************************/ michael@0: michael@0: /** michael@0: * thread-safe conversion routines that do not depend on uconv libraries. michael@0: */ michael@0: nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString &output); michael@0: nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &output); michael@0: michael@0: /* michael@0: * This function indicates whether the character encoding used in the file michael@0: * system (more exactly what's used for |GetNativeFoo| and |SetNativeFoo| michael@0: * of |nsIFile|) is UTF-8 or not. Knowing that helps us avoid an michael@0: * unncessary encoding conversion in some cases. For instance, to get the leaf michael@0: * name in UTF-8 out of nsIFile, we can just use |GetNativeLeafName| rather michael@0: * than using |GetLeafName| and converting the result to UTF-8 if the file michael@0: * system encoding is UTF-8. michael@0: * On Unix (but not on Mac OS X), it depends on the locale and is not known michael@0: * in advance (at the compilation time) so that this function needs to be michael@0: * a real function. On Mac OS X it's always UTF-8 while on Windows michael@0: * and other platforms (e.g. OS2), it's never UTF-8. michael@0: */ michael@0: #if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(ANDROID) michael@0: bool NS_IsNativeUTF8(); michael@0: #else michael@0: inline bool NS_IsNativeUTF8() michael@0: { michael@0: #if defined(XP_MACOSX) || defined(ANDROID) michael@0: return true; michael@0: #else michael@0: return false; michael@0: #endif michael@0: } michael@0: #endif michael@0: michael@0: michael@0: /** michael@0: * internal michael@0: */ michael@0: void NS_StartupNativeCharsetUtils(); michael@0: void NS_ShutdownNativeCharsetUtils(); michael@0: michael@0: #endif // nsNativeCharsetUtils_h__