OLD | NEW |
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 <limits> | 7 #include <limits> |
8 | 8 |
9 #include "../../include/fxcrt/fx_ext.h" | 9 #include "../../include/fxcrt/fx_ext.h" |
10 #include "../../include/fxcrt/fx_string.h" | 10 #include "../../include/fxcrt/fx_string.h" |
(...skipping 190 matching lines...) Loading... |
201 } | 201 } |
202 #ifdef __cplusplus | 202 #ifdef __cplusplus |
203 } | 203 } |
204 #endif | 204 #endif |
205 #endif | 205 #endif |
206 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 206 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
207 #ifdef __cplusplus | 207 #ifdef __cplusplus |
208 extern "C" { | 208 extern "C" { |
209 #endif | 209 #endif |
210 int FXSYS_WideCharToMultiByte(FX_DWORD codepage, FX_DWORD dwFlags, const FX_WCHA
R* wstr, int wlen, | 210 int FXSYS_WideCharToMultiByte(FX_DWORD codepage, FX_DWORD dwFlags, const FX_WCHA
R* wstr, int wlen, |
211 FX_CHAR* buf, int buflen, const FX_CHAR* default_s
tr, FX_BOOL* pUseDefault) | 211 FX_CHAR* buf, int buflen, const FX_CHAR* default_s
tr, int* pUseDefault) |
212 { | 212 { |
213 int len = 0; | 213 int len = 0; |
214 for (int i = 0; i < wlen; i ++) { | 214 for (int i = 0; i < wlen; i ++) { |
215 if (wstr[i] < 0x100) { | 215 if (wstr[i] < 0x100) { |
216 if (buf && len < buflen) { | 216 if (buf && len < buflen) { |
217 buf[len] = (FX_CHAR)wstr[i]; | 217 buf[len] = (FX_CHAR)wstr[i]; |
218 } | 218 } |
219 len ++; | 219 len ++; |
220 } | 220 } |
221 } | 221 } |
222 return len; | 222 return len; |
223 } | 223 } |
224 int FXSYS_MultiByteToWideChar(FX_DWORD codepage, FX_DWORD dwFlags, const FX_CHAR
* bstr, int blen, | 224 int FXSYS_MultiByteToWideChar(FX_DWORD codepage, FX_DWORD dwFlags, const FX_CHAR
* bstr, int blen, |
225 FX_WCHAR* buf, int buflen) | 225 FX_WCHAR* buf, int buflen) |
226 { | 226 { |
227 int wlen = 0; | 227 int wlen = 0; |
228 for (int i = 0; i < blen; i ++) { | 228 for (int i = 0; i < blen; i ++) { |
229 if (buf && wlen < buflen) { | 229 if (buf && wlen < buflen) { |
230 buf[wlen] = bstr[i]; | 230 buf[wlen] = bstr[i]; |
231 } | 231 } |
232 wlen ++; | 232 wlen ++; |
233 } | 233 } |
234 return wlen; | 234 return wlen; |
235 } | 235 } |
236 #ifdef __cplusplus | 236 #ifdef __cplusplus |
237 } | 237 } |
238 #endif | 238 #endif |
239 #endif | 239 #endif |
OLD | NEW |