1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // This file defines utility functions for escaping strings.
7 #ifndef BASE_JSON_STRING_ESCAPE_H_
8 #define BASE_JSON_STRING_ESCAPE_H_
12 #include "base/base_export.h"
13 #include "base/string16.h"
17 // Escape |str| appropriately for a JSON string literal, _appending_ the
18 // result to |dst|. This will create unicode escape sequences (\uXXXX).
19 // If |put_in_quotes| is true, the result will be surrounded in double quotes.
20 // The outputted literal, when interpreted by the browser, should result in a
21 // javascript string that is identical and the same length as the input |str|.
22 BASE_EXPORT
void JsonDoubleQuote(const std::string
& str
,
26 // Same as above, but always returns the result double quoted.
27 BASE_EXPORT
std::string
GetDoubleQuotedJson(const std::string
& str
);
29 BASE_EXPORT
void JsonDoubleQuote(const string16
& str
,
33 // Same as above, but always returns the result double quoted.
34 BASE_EXPORT
std::string
GetDoubleQuotedJson(const string16
& str
);
38 #endif // BASE_JSON_STRING_ESCAPE_H_