diff options
author | Jacek Antonelli | 2009-04-30 13:04:20 -0500 |
---|---|---|
committer | Jacek Antonelli | 2009-04-30 13:07:16 -0500 |
commit | ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e (patch) | |
tree | 8348301d0ac44a524f1819b777686bf086907d76 /linden/indra/llcommon/llstring.cpp | |
parent | Second Life viewer sources 1.22.11 (diff) | |
download | meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.zip meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.gz meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.bz2 meta-impy-ca8149ca6d157eb4b5fc8ba0e5ba3a6e56f72e7e.tar.xz |
Second Life viewer sources 1.23.0-RC
Diffstat (limited to 'linden/indra/llcommon/llstring.cpp')
-rw-r--r-- | linden/indra/llcommon/llstring.cpp | 57 |
1 files changed, 23 insertions, 34 deletions
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 @@ | |||
17 | * There are special exceptions to the terms and conditions of the GPL as | 17 | * There are special exceptions to the terms and conditions of the GPL as |
18 | * it is applied to this Source Code. View the full text of the exception | 18 | * it is applied to this Source Code. View the full text of the exception |
19 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 19 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
20 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception | 20 | * online at |
21 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
21 | * | 22 | * |
22 | * By copying, modifying or distributing this software, you acknowledge | 23 | * By copying, modifying or distributing this software, you acknowledge |
23 | * that you have read and understood your obligations described above, | 24 | * that you have read and understood your obligations described above, |
@@ -662,7 +663,8 @@ S32 LLStringOps::collate(const llwchar* a, const llwchar* b) | |||
662 | 663 | ||
663 | namespace LLStringFn | 664 | namespace LLStringFn |
664 | { | 665 | { |
665 | void replace_nonprintable(std::basic_string<char>& string, char replacement) | 666 | // NOTE - this restricts output to ascii |
667 | void replace_nonprintable_in_ascii(std::basic_string<char>& string, char replacement) | ||
666 | { | 668 | { |
667 | const char MIN = 0x20; | 669 | const char MIN = 0x20; |
668 | std::basic_string<char>::size_type len = string.size(); | 670 | std::basic_string<char>::size_type len = string.size(); |
@@ -675,23 +677,9 @@ namespace LLStringFn | |||
675 | } | 677 | } |
676 | } | 678 | } |
677 | 679 | ||
678 | void replace_nonprintable( | ||
679 | std::basic_string<llwchar>& string, | ||
680 | llwchar replacement) | ||
681 | { | ||
682 | const llwchar MIN = 0x20; | ||
683 | const llwchar MAX = 0x7f; | ||
684 | std::basic_string<llwchar>::size_type len = string.size(); | ||
685 | for(std::basic_string<llwchar>::size_type ii = 0; ii < len; ++ii) | ||
686 | { | ||
687 | if((string[ii] < MIN) || (string[ii] > MAX)) | ||
688 | { | ||
689 | string[ii] = replacement; | ||
690 | } | ||
691 | } | ||
692 | } | ||
693 | 680 | ||
694 | void replace_nonprintable_and_pipe(std::basic_string<char>& str, | 681 | // NOTE - this restricts output to ascii |
682 | void replace_nonprintable_and_pipe_in_ascii(std::basic_string<char>& str, | ||
695 | char replacement) | 683 | char replacement) |
696 | { | 684 | { |
697 | const char MIN = 0x20; | 685 | const char MIN = 0x20; |
@@ -706,22 +694,6 @@ namespace LLStringFn | |||
706 | } | 694 | } |
707 | } | 695 | } |
708 | 696 | ||
709 | void replace_nonprintable_and_pipe(std::basic_string<llwchar>& str, | ||
710 | llwchar replacement) | ||
711 | { | ||
712 | const llwchar MIN = 0x20; | ||
713 | const llwchar MAX = 0x7f; | ||
714 | const llwchar PIPE = 0x7c; | ||
715 | std::basic_string<llwchar>::size_type len = str.size(); | ||
716 | for(std::basic_string<llwchar>::size_type ii = 0; ii < len; ++ii) | ||
717 | { | ||
718 | if( (str[ii] < MIN) || (str[ii] > MAX) || (str[ii] == PIPE) ) | ||
719 | { | ||
720 | str[ii] = replacement; | ||
721 | } | ||
722 | } | ||
723 | } | ||
724 | |||
725 | // https://wiki.lindenlab.com/wiki/Unicode_Guidelines has details on | 697 | // https://wiki.lindenlab.com/wiki/Unicode_Guidelines has details on |
726 | // allowable code points for XML. Specifically, they are: | 698 | // allowable code points for XML. Specifically, they are: |
727 | // 0x09, 0x0a, 0x0d, and 0x20 on up. JC | 699 | // 0x09, 0x0a, 0x0d, and 0x20 on up. JC |
@@ -747,6 +719,23 @@ namespace LLStringFn | |||
747 | return output; | 719 | return output; |
748 | } | 720 | } |
749 | 721 | ||
722 | /** | ||
723 | * @brief Replace all control characters (c < 0x20) with replacement in | ||
724 | * string. | ||
725 | */ | ||
726 | void replace_ascii_controlchars(std::basic_string<char>& string, char replacement) | ||
727 | { | ||
728 | const unsigned char MIN = 0x20; | ||
729 | std::basic_string<char>::size_type len = string.size(); | ||
730 | for(std::basic_string<char>::size_type ii = 0; ii < len; ++ii) | ||
731 | { | ||
732 | const unsigned char c = (unsigned char) string[ii]; | ||
733 | if(c < MIN) | ||
734 | { | ||
735 | string[ii] = replacement; | ||
736 | } | ||
737 | } | ||
738 | } | ||
750 | } | 739 | } |
751 | 740 | ||
752 | 741 | ||