1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/xpcom/io/nsNativeCharsetUtils.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.5 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.7 + 1.8 +#ifndef nsNativeCharsetUtils_h__ 1.9 +#define nsNativeCharsetUtils_h__ 1.10 + 1.11 + 1.12 +/*****************************************************************************\ 1.13 + * * 1.14 + * **** NOTICE **** * 1.15 + * * 1.16 + * *** THESE ARE NOT GENERAL PURPOSE CONVERTERS *** * 1.17 + * * 1.18 + * NS_CopyNativeToUnicode / NS_CopyUnicodeToNative should only be used * 1.19 + * for converting *FILENAMES* between native and unicode. They are not * 1.20 + * designed or tested for general encoding converter use. * 1.21 + * * 1.22 +\*****************************************************************************/ 1.23 + 1.24 +/** 1.25 + * thread-safe conversion routines that do not depend on uconv libraries. 1.26 + */ 1.27 +nsresult NS_CopyNativeToUnicode(const nsACString &input, nsAString &output); 1.28 +nsresult NS_CopyUnicodeToNative(const nsAString &input, nsACString &output); 1.29 + 1.30 +/* 1.31 + * This function indicates whether the character encoding used in the file 1.32 + * system (more exactly what's used for |GetNativeFoo| and |SetNativeFoo| 1.33 + * of |nsIFile|) is UTF-8 or not. Knowing that helps us avoid an 1.34 + * unncessary encoding conversion in some cases. For instance, to get the leaf 1.35 + * name in UTF-8 out of nsIFile, we can just use |GetNativeLeafName| rather 1.36 + * than using |GetLeafName| and converting the result to UTF-8 if the file 1.37 + * system encoding is UTF-8. 1.38 + * On Unix (but not on Mac OS X), it depends on the locale and is not known 1.39 + * in advance (at the compilation time) so that this function needs to be 1.40 + * a real function. On Mac OS X it's always UTF-8 while on Windows 1.41 + * and other platforms (e.g. OS2), it's never UTF-8. 1.42 + */ 1.43 +#if defined(XP_UNIX) && !defined(XP_MACOSX) && !defined(ANDROID) 1.44 +bool NS_IsNativeUTF8(); 1.45 +#else 1.46 +inline bool NS_IsNativeUTF8() 1.47 +{ 1.48 +#if defined(XP_MACOSX) || defined(ANDROID) 1.49 + return true; 1.50 +#else 1.51 + return false; 1.52 +#endif 1.53 +} 1.54 +#endif 1.55 + 1.56 + 1.57 +/** 1.58 + * internal 1.59 + */ 1.60 +void NS_StartupNativeCharsetUtils(); 1.61 +void NS_ShutdownNativeCharsetUtils(); 1.62 + 1.63 +#endif // nsNativeCharsetUtils_h__