From ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Thu, 30 Apr 2009 13:04:20 -0500 Subject: Second Life viewer sources 1.23.0-RC --- linden/indra/llcommon/llstring.cpp | 57 +++++++++++++++----------------------- 1 file changed, 23 insertions(+), 34 deletions(-) (limited to 'linden/indra/llcommon/llstring.cpp') diff --git a/linden/indra/llcommon/llstring.cpp b/linden/indra/llcommon/llstring.cpp index dfd131b..1f653c1 100644 --- a/linden/indra/llcommon/llstring.cpp +++ b/linden/indra/llcommon/llstring.cpp @@ -17,7 +17,8 @@ * There are special exceptions to the terms and conditions of the GPL as * it is applied to this Source Code. View the full text of the exception * in the file doc/FLOSS-exception.txt in this software distribution, or - * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception + * online at + * http://secondlifegrid.net/programs/open_source/licensing/flossexception * * By copying, modifying or distributing this software, you acknowledge * that you have read and understood your obligations described above, @@ -662,7 +663,8 @@ S32 LLStringOps::collate(const llwchar* a, const llwchar* b) namespace LLStringFn { - void replace_nonprintable(std::basic_string& string, char replacement) + // NOTE - this restricts output to ascii + void replace_nonprintable_in_ascii(std::basic_string& string, char replacement) { const char MIN = 0x20; std::basic_string::size_type len = string.size(); @@ -675,23 +677,9 @@ namespace LLStringFn } } - void replace_nonprintable( - std::basic_string& string, - llwchar replacement) - { - const llwchar MIN = 0x20; - const llwchar MAX = 0x7f; - std::basic_string::size_type len = string.size(); - for(std::basic_string::size_type ii = 0; ii < len; ++ii) - { - if((string[ii] < MIN) || (string[ii] > MAX)) - { - string[ii] = replacement; - } - } - } - void replace_nonprintable_and_pipe(std::basic_string& str, + // NOTE - this restricts output to ascii + void replace_nonprintable_and_pipe_in_ascii(std::basic_string& str, char replacement) { const char MIN = 0x20; @@ -706,22 +694,6 @@ namespace LLStringFn } } - void replace_nonprintable_and_pipe(std::basic_string& str, - llwchar replacement) - { - const llwchar MIN = 0x20; - const llwchar MAX = 0x7f; - const llwchar PIPE = 0x7c; - std::basic_string::size_type len = str.size(); - for(std::basic_string::size_type ii = 0; ii < len; ++ii) - { - if( (str[ii] < MIN) || (str[ii] > MAX) || (str[ii] == PIPE) ) - { - str[ii] = replacement; - } - } - } - // https://wiki.lindenlab.com/wiki/Unicode_Guidelines has details on // allowable code points for XML. Specifically, they are: // 0x09, 0x0a, 0x0d, and 0x20 on up. JC @@ -747,6 +719,23 @@ namespace LLStringFn return output; } + /** + * @brief Replace all control characters (c < 0x20) with replacement in + * string. + */ + void replace_ascii_controlchars(std::basic_string& string, char replacement) + { + const unsigned char MIN = 0x20; + std::basic_string::size_type len = string.size(); + for(std::basic_string::size_type ii = 0; ii < len; ++ii) + { + const unsigned char c = (unsigned char) string[ii]; + if(c < MIN) + { + string[ii] = replacement; + } + } + } } -- cgit v1.1