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 "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" | 7 #include "core/fpdfapi/fpdf_parser/fpdf_parser_utility.h" |
8 | 8 |
9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" | 9 #include "core/fpdfapi/fpdf_parser/include/cpdf_array.h" |
10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" | 10 #include "core/fpdfapi/fpdf_parser/include/cpdf_dictionary.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 } | 105 } |
106 } | 106 } |
107 result.ReleaseBuffer((FX_STRSIZE)(pDest - pDestStart)); | 107 result.ReleaseBuffer((FX_STRSIZE)(pDest - pDestStart)); |
108 return result; | 108 return result; |
109 } | 109 } |
110 | 110 |
111 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) { | 111 CFX_ByteString PDF_NameDecode(const CFX_ByteString& orig) { |
112 if (!FXSYS_memchr(orig.c_str(), '#', orig.GetLength())) { | 112 if (!FXSYS_memchr(orig.c_str(), '#', orig.GetLength())) { |
113 return orig; | 113 return orig; |
114 } | 114 } |
115 return PDF_NameDecode(CFX_ByteStringC(orig)); | 115 return PDF_NameDecode(orig.AsStringC()); |
116 } | 116 } |
117 | 117 |
118 CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) { | 118 CFX_ByteString PDF_NameEncode(const CFX_ByteString& orig) { |
119 uint8_t* src_buf = (uint8_t*)orig.c_str(); | 119 uint8_t* src_buf = (uint8_t*)orig.c_str(); |
120 int src_len = orig.GetLength(); | 120 int src_len = orig.GetLength(); |
121 int dest_len = 0; | 121 int dest_len = 0; |
122 int i; | 122 int i; |
123 for (i = 0; i < src_len; i++) { | 123 for (i = 0; i < src_len; i++) { |
124 uint8_t ch = src_buf[i]; | 124 uint8_t ch = src_buf[i]; |
125 if (ch >= 0x80 || PDFCharIsWhitespace(ch) || ch == '#' || | 125 if (ch >= 0x80 || PDFCharIsWhitespace(ch) || ch == '#' || |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 buf.AppendBlock(acc.GetData(), acc.GetSize()); | 214 buf.AppendBlock(acc.GetData(), acc.GetSize()); |
215 buf << "\r\nendstream"; | 215 buf << "\r\nendstream"; |
216 break; | 216 break; |
217 } | 217 } |
218 default: | 218 default: |
219 ASSERT(FALSE); | 219 ASSERT(FALSE); |
220 break; | 220 break; |
221 } | 221 } |
222 return buf; | 222 return buf; |
223 } | 223 } |
OLD | NEW |