summaryrefslogtreecommitdiffstats
path: root/base/string_util.h
diff options
context:
space:
mode:
authormmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-14 01:25:32 +0000
committermmentovai@google.com <mmentovai@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-14 01:25:32 +0000
commit44cd16fcc85697b5094250a89decaab5c692b392 (patch)
tree37e4fb0dbee34f2cc673c287b54515a71b1f9629 /base/string_util.h
parent5f800edb90578f08b3462e1dc96b78bf0ec56d36 (diff)
downloadchromium_src-44cd16fcc85697b5094250a89decaab5c692b392.zip
chromium_src-44cd16fcc85697b5094250a89decaab5c692b392.tar.gz
chromium_src-44cd16fcc85697b5094250a89decaab5c692b392.tar.bz2
DCHECK vswprintf format string cross-platform portability. Use %ls, not %s, for wchar_t* fields.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@849 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.h')
-rw-r--r--base/string_util.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/base/string_util.h b/base/string_util.h
index 5faa9cf..ca0496c 100644
--- a/base/string_util.h
+++ b/base/string_util.h
@@ -92,6 +92,29 @@ inline int swprintf(wchar_t* buffer, size_t size, const wchar_t* format, ...) {
size_t strlcpy(char* dst, const char* src, size_t dst_size);
size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size);
+// Scan a wprintf format string to determine whether it's portable across a
+// variety of systems. This function only checks that the conversion
+// specifiers used by the format string are supported and have the same meaning
+// on a variety of systems. It doesn't check for other errors that might occur
+// within a format string.
+//
+// Nonportable conversion specifiers for wprintf are:
+// - 's' and 'c' without an 'l' length modifier. %s and %c operate on char
+// data on all systems except Windows, which treat them as wchar_t data.
+// Use %ls and %lc for wchar_t data instead.
+// - 'S' and 'C', which operate on wchar_t data on all systems except Windows,
+// which treat them as char data. Use %ls and %lc for wchar_t data
+// instead.
+// - 'F', which is not identified by Windows wprintf documentation.
+// - 'D', 'O', and 'U', which are deprecated and not available on all systems.
+// Use %ld, %lo, and %lu instead.
+//
+// Note that there is no portable conversion specifier for char data when
+// working with wprintf.
+//
+// This function is intended to be called from base::vswprintf.
+bool IsWprintfFormatPortable(const wchar_t* format);
+
} // namespace base
#if defined(OS_WIN)