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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <cctype> | 10 #include <cctype> |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 | 817 |
818 // static | 818 // static |
819 CFX_ByteString CFX_ByteString::FromUnicode(const FX_WCHAR* str, | 819 CFX_ByteString CFX_ByteString::FromUnicode(const FX_WCHAR* str, |
820 FX_STRSIZE len) { | 820 FX_STRSIZE len) { |
821 FX_STRSIZE str_len = len >= 0 ? len : FXSYS_wcslen(str); | 821 FX_STRSIZE str_len = len >= 0 ? len : FXSYS_wcslen(str); |
822 return FromUnicode(CFX_WideString(str, str_len)); | 822 return FromUnicode(CFX_WideString(str, str_len)); |
823 } | 823 } |
824 | 824 |
825 // static | 825 // static |
826 CFX_ByteString CFX_ByteString::FromUnicode(const CFX_WideString& str) { | 826 CFX_ByteString CFX_ByteString::FromUnicode(const CFX_WideString& str) { |
827 return CFX_CharMap::GetByteString(0, str.AsWideStringC()); | 827 return CFX_CharMap::GetByteString(0, str.AsStringC()); |
828 } | 828 } |
829 | 829 |
830 int CFX_ByteString::Compare(const CFX_ByteStringC& str) const { | 830 int CFX_ByteString::Compare(const CFX_ByteStringC& str) const { |
831 if (!m_pData) { | 831 if (!m_pData) { |
832 return str.IsEmpty() ? 0 : -1; | 832 return str.IsEmpty() ? 0 : -1; |
833 } | 833 } |
834 int this_len = m_pData->m_nDataLength; | 834 int this_len = m_pData->m_nDataLength; |
835 int that_len = str.GetLength(); | 835 int that_len = str.GetLength(); |
836 int min_len = this_len < that_len ? this_len : that_len; | 836 int min_len = this_len < that_len ? this_len : that_len; |
837 for (int i = 0; i < min_len; i++) { | 837 for (int i = 0; i < min_len; i++) { |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 fraction %= scale; | 988 fraction %= scale; |
989 scale /= 10; | 989 scale /= 10; |
990 } | 990 } |
991 return buf_size; | 991 return buf_size; |
992 } | 992 } |
993 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { | 993 CFX_ByteString CFX_ByteString::FormatFloat(FX_FLOAT d, int precision) { |
994 FX_CHAR buf[32]; | 994 FX_CHAR buf[32]; |
995 FX_STRSIZE len = FX_ftoa(d, buf); | 995 FX_STRSIZE len = FX_ftoa(d, buf); |
996 return CFX_ByteString(buf, len); | 996 return CFX_ByteString(buf, len); |
997 } | 997 } |
OLD | NEW |