| 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 "fpdfsdk/javascript/util.h" | 7 #include "fpdfsdk/javascript/util.h" |
| 8 | 8 |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 vRet.SetNull(); | 439 vRet.SetNull(); |
| 440 } | 440 } |
| 441 | 441 |
| 442 return TRUE; | 442 return TRUE; |
| 443 } | 443 } |
| 444 | 444 |
| 445 FX_BOOL util::byteToChar(IJS_Context* cc, | 445 FX_BOOL util::byteToChar(IJS_Context* cc, |
| 446 const std::vector<CJS_Value>& params, | 446 const std::vector<CJS_Value>& params, |
| 447 CJS_Value& vRet, | 447 CJS_Value& vRet, |
| 448 CFX_WideString& sError) { | 448 CFX_WideString& sError) { |
| 449 int iSize = params.size(); | 449 CJS_Context* pContext = static_cast<CJS_Context*>(cc); |
| 450 if (iSize == 0) | 450 if (params.size() < 1) { |
| 451 sError = JSGetStringFromID(pContext, IDS_STRING_JSPARAMERROR); |
| 451 return FALSE; | 452 return FALSE; |
| 452 int nByte = params[0].ToInt(); | 453 } |
| 453 unsigned char cByte = (unsigned char)nByte; | 454 int arg = params[0].ToInt(); |
| 454 CFX_WideString csValue; | 455 if (arg < 0 || arg > 255) { |
| 455 csValue.Format(L"%c", cByte); | 456 sError = JSGetStringFromID(pContext, IDS_STRING_JSVALUEERROR); |
| 456 vRet = csValue.c_str(); | 457 return FALSE; |
| 458 } |
| 459 CFX_WideString wStr(static_cast<FX_WCHAR>(arg)); |
| 460 vRet = wStr.c_str(); |
| 457 return TRUE; | 461 return TRUE; |
| 458 } | 462 } |
| OLD | NEW |