| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/string_util.h" | 5 #include "base/string_util.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 | 8 |
| 9 #include <ctype.h> | 9 #include <ctype.h> |
| 10 #include <errno.h> | 10 #include <errno.h> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 } | 110 } |
| 111 | 111 |
| 112 const std::wstring& EmptyWString() { | 112 const std::wstring& EmptyWString() { |
| 113 return EmptyStrings::GetInstance()->ws; | 113 return EmptyStrings::GetInstance()->ws; |
| 114 } | 114 } |
| 115 | 115 |
| 116 const string16& EmptyString16() { | 116 const string16& EmptyString16() { |
| 117 return EmptyStrings::GetInstance()->s16; | 117 return EmptyStrings::GetInstance()->s16; |
| 118 } | 118 } |
| 119 | 119 |
| 120 #define WHITESPACE_UNICODE \ | |
| 121 0x0009, /* <control-0009> to <control-000D> */ \ | |
| 122 0x000A, \ | |
| 123 0x000B, \ | |
| 124 0x000C, \ | |
| 125 0x000D, \ | |
| 126 0x0020, /* Space */ \ | |
| 127 0x0085, /* <control-0085> */ \ | |
| 128 0x00A0, /* No-Break Space */ \ | |
| 129 0x1680, /* Ogham Space Mark */ \ | |
| 130 0x180E, /* Mongolian Vowel Separator */ \ | |
| 131 0x2000, /* En Quad to Hair Space */ \ | |
| 132 0x2001, \ | |
| 133 0x2002, \ | |
| 134 0x2003, \ | |
| 135 0x2004, \ | |
| 136 0x2005, \ | |
| 137 0x2006, \ | |
| 138 0x2007, \ | |
| 139 0x2008, \ | |
| 140 0x2009, \ | |
| 141 0x200A, \ | |
| 142 0x200C, /* Zero Width Non-Joiner */ \ | |
| 143 0x2028, /* Line Separator */ \ | |
| 144 0x2029, /* Paragraph Separator */ \ | |
| 145 0x202F, /* Narrow No-Break Space */ \ | |
| 146 0x205F, /* Medium Mathematical Space */ \ | |
| 147 0x3000, /* Ideographic Space */ \ | |
| 148 0 | |
| 149 | |
| 150 const wchar_t kWhitespaceWide[] = { | |
| 151 WHITESPACE_UNICODE | |
| 152 }; | |
| 153 const char16 kWhitespaceUTF16[] = { | |
| 154 WHITESPACE_UNICODE | |
| 155 }; | |
| 156 const char kWhitespaceASCII[] = { | |
| 157 0x09, // <control-0009> to <control-000D> | |
| 158 0x0A, | |
| 159 0x0B, | |
| 160 0x0C, | |
| 161 0x0D, | |
| 162 0x20, // Space | |
| 163 0 | |
| 164 }; | |
| 165 | |
| 166 const char kUtf8ByteOrderMark[] = "\xEF\xBB\xBF"; | |
| 167 | |
| 168 template<typename STR> | 120 template<typename STR> |
| 169 bool RemoveCharsT(const STR& input, | 121 bool RemoveCharsT(const STR& input, |
| 170 const typename STR::value_type remove_chars[], | 122 const typename STR::value_type remove_chars[], |
| 171 STR* output) { | 123 STR* output) { |
| 172 bool removed = false; | 124 bool removed = false; |
| 173 size_t found; | 125 size_t found; |
| 174 | 126 |
| 175 *output = input; | 127 *output = input; |
| 176 | 128 |
| 177 found = output->find_first_of(remove_chars); | 129 found = output->find_first_of(remove_chars); |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1088 } | 1040 } |
| 1089 | 1041 |
| 1090 } // namespace | 1042 } // namespace |
| 1091 | 1043 |
| 1092 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { | 1044 size_t base::strlcpy(char* dst, const char* src, size_t dst_size) { |
| 1093 return lcpyT<char>(dst, src, dst_size); | 1045 return lcpyT<char>(dst, src, dst_size); |
| 1094 } | 1046 } |
| 1095 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { | 1047 size_t base::wcslcpy(wchar_t* dst, const wchar_t* src, size_t dst_size) { |
| 1096 return lcpyT<wchar_t>(dst, src, dst_size); | 1048 return lcpyT<wchar_t>(dst, src, dst_size); |
| 1097 } | 1049 } |
| OLD | NEW |