diff options
author | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 16:43:49 +0000 |
---|---|---|
committer | erikkay@google.com <erikkay@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-20 16:43:49 +0000 |
commit | d36519b5068d92f4e71b8d6fd51eda2c42e54e38 (patch) | |
tree | 6aaf53187b1a36cc1d1f45c8f5ca994d55900650 /base/string_escape.h | |
parent | c66cd7d3bfe3b572c7824db8c7d8d5c71cd21afd (diff) | |
download | chromium_src-d36519b5068d92f4e71b8d6fd51eda2c42e54e38.zip chromium_src-d36519b5068d92f4e71b8d6fd51eda2c42e54e38.tar.gz chromium_src-d36519b5068d92f4e71b8d6fd51eda2c42e54e38.tar.bz2 |
Add JSON-specific escaping, which has different rules from JS escaping.BUG=http://crbug.com/11431TEST=base_unittests.exe --gtest_filter=StringEscapeTest.Json*
Review URL: http://codereview.chromium.org/113606
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@16485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_escape.h')
-rw-r--r-- | base/string_escape.h | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/base/string_escape.h b/base/string_escape.h index 9c6233a..3f0bf3f 100644 --- a/base/string_escape.h +++ b/base/string_escape.h @@ -7,28 +7,25 @@ #ifndef BASE_STRING_ESCAPE_H__ #define BASE_STRING_ESCAPE_H__ +#include <string> + #include "base/string16.h" namespace string_escape { -// Escape |str| appropriately for a javascript string litereal, _appending_ the -// result to |dst|. This will create standard escape sequences (\b, \n), -// hex escape sequences (\x00), and unicode escape sequences (\uXXXX). +// Escape |str| appropriately for a JSON string litereal, _appending_ the +// result to |dst|. This will create unicode escape sequences (\uXXXX). // If |put_in_quotes| is true, the result will be surrounded in double quotes. // The outputted literal, when interpreted by the browser, should result in a // javascript string that is identical and the same length as the input |str|. -void JavascriptDoubleQuote(const string16& str, - bool put_in_quotes, - std::string* dst); - -// Similar to the wide version, but for narrow strings. It will not use -// \uXXXX unicode escape sequences. It will pass non-7bit characters directly -// into the string unencoded, allowing the browser to interpret the encoding. -// The outputted literal, when interpreted by the browser, could result in a -// javascript string of a different length than the input |str|. -void JavascriptDoubleQuote(const std::string& str, - bool put_in_quotes, - std::string* dst); +void JsonDoubleQuote(const std::string& str, + bool put_in_quotes, + std::string* dst); + +void JsonDoubleQuote(const string16& str, + bool put_in_quotes, + std::string* dst); + } // namespace string_escape |