Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: core/fxcrt/fx_basic_gcc.cpp

Issue 1972053003: Add CFX_ByteStringC::CharAt() to avoid c_str() and casts (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « core/fxcrt/fx_basic_bstring.cpp ('k') | core/fxcrt/fx_basic_util.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium 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 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <cctype> 7 #include <cctype>
8 #include <cwctype> 8 #include <cwctype>
9 #include <limits> 9 #include <limits>
10 10
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 uint32_t dwFlags, 219 uint32_t dwFlags,
220 const FX_WCHAR* wstr, 220 const FX_WCHAR* wstr,
221 int wlen, 221 int wlen,
222 FX_CHAR* buf, 222 FX_CHAR* buf,
223 int buflen, 223 int buflen,
224 const FX_CHAR* default_str, 224 const FX_CHAR* default_str,
225 int* pUseDefault) { 225 int* pUseDefault) {
226 int len = 0; 226 int len = 0;
227 for (int i = 0; i < wlen; i++) { 227 for (int i = 0; i < wlen; i++) {
228 if (wstr[i] < 0x100) { 228 if (wstr[i] < 0x100) {
229 if (buf && len < buflen) { 229 if (buf && len < buflen)
230 buf[len] = (FX_CHAR)wstr[i]; 230 buf[len] = static_cast<FX_CHAR>(wstr[i]);
231 }
232 len++; 231 len++;
233 } 232 }
234 } 233 }
235 return len; 234 return len;
236 } 235 }
237 int FXSYS_MultiByteToWideChar(uint32_t codepage, 236 int FXSYS_MultiByteToWideChar(uint32_t codepage,
238 uint32_t dwFlags, 237 uint32_t dwFlags,
239 const FX_CHAR* bstr, 238 const FX_CHAR* bstr,
240 int blen, 239 int blen,
241 FX_WCHAR* buf, 240 FX_WCHAR* buf,
242 int buflen) { 241 int buflen) {
243 int wlen = 0; 242 int wlen = 0;
244 for (int i = 0; i < blen; i++) { 243 for (int i = 0; i < blen; i++) {
245 if (buf && wlen < buflen) { 244 if (buf && wlen < buflen) {
246 buf[wlen] = bstr[i]; 245 buf[wlen] = bstr[i];
247 } 246 }
248 wlen++; 247 wlen++;
249 } 248 }
250 return wlen; 249 return wlen;
251 } 250 }
252 #ifdef __cplusplus 251 #ifdef __cplusplus
253 } 252 }
254 #endif 253 #endif
255 #endif 254 #endif
OLDNEW
« no previous file with comments | « core/fxcrt/fx_basic_bstring.cpp ('k') | core/fxcrt/fx_basic_util.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698