]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
3868d06d | 2 | Unicode and ASCII string primitives.\r |
e1f414b6 | 3 | \r |
ea2e0921 | 4 | Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r |
bb817c56 | 5 | This program and the accompanying materials\r |
e1f414b6 | 6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
127010dd | 8 | http://opensource.org/licenses/bsd-license.php.\r |
e1f414b6 | 9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
e1f414b6 | 13 | **/\r |
14 | \r | |
e1f414b6 | 15 | #include "BaseLibInternals.h"\r |
16 | \r | |
1bb390f1 | 17 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
24dcb5e5 | 18 | \r |
e1f414b6 | 19 | /**\r |
1bb390f1 ED |
20 | [ATTENTION] This function will be deprecated for security reason.\r |
21 | \r | |
e1f414b6 | 22 | Copies one Null-terminated Unicode string to another Null-terminated Unicode\r |
23 | string and returns the new Unicode string.\r | |
24 | \r | |
25 | This function copies the contents of the Unicode string Source to the Unicode\r | |
26 | string Destination, and returns Destination. If Source and Destination\r | |
27 | overlap, then the results are undefined.\r | |
28 | \r | |
29 | If Destination is NULL, then ASSERT().\r | |
30 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
31 | If Source is NULL, then ASSERT().\r | |
32 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
33 | If Source and Destination overlap, then ASSERT().\r | |
34 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
dfbe9de9 | 35 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
e1f414b6 | 36 | Null-terminator, then ASSERT().\r |
37 | \r | |
127010dd | 38 | @param Destination A pointer to a Null-terminated Unicode string.\r |
39 | @param Source A pointer to a Null-terminated Unicode string.\r | |
e1f414b6 | 40 | \r |
9aa049d9 | 41 | @return Destination.\r |
e1f414b6 | 42 | \r |
43 | **/\r | |
44 | CHAR16 *\r | |
45 | EFIAPI\r | |
46 | StrCpy (\r | |
47 | OUT CHAR16 *Destination,\r | |
48 | IN CONST CHAR16 *Source\r | |
49 | )\r | |
50 | {\r | |
51 | CHAR16 *ReturnValue;\r | |
52 | \r | |
53 | //\r | |
54 | // Destination cannot be NULL\r | |
55 | //\r | |
56 | ASSERT (Destination != NULL);\r | |
24dcb5e5 | 57 | ASSERT (((UINTN) Destination & BIT0) == 0);\r |
e1f414b6 | 58 | \r |
59 | //\r | |
60 | // Destination and source cannot overlap\r | |
61 | //\r | |
62 | ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r | |
63 | ASSERT ((UINTN)(Source - Destination) > StrLen (Source));\r | |
64 | \r | |
65 | ReturnValue = Destination;\r | |
42eedea9 | 66 | while (*Source != 0) {\r |
e1f414b6 | 67 | *(Destination++) = *(Source++);\r |
68 | }\r | |
69 | *Destination = 0;\r | |
70 | return ReturnValue;\r | |
71 | }\r | |
72 | \r | |
73 | /**\r | |
1bb390f1 ED |
74 | [ATTENTION] This function will be deprecated for security reason.\r |
75 | \r | |
9aa049d9 | 76 | Copies up to a specified length from one Null-terminated Unicode string to \r |
77 | another Null-terminated Unicode string and returns the new Unicode string.\r | |
e1f414b6 | 78 | \r |
79 | This function copies the contents of the Unicode string Source to the Unicode\r | |
80 | string Destination, and returns Destination. At most, Length Unicode\r | |
81 | characters are copied from Source to Destination. If Length is 0, then\r | |
82 | Destination is returned unmodified. If Length is greater that the number of\r | |
83 | Unicode characters in Source, then Destination is padded with Null Unicode\r | |
84 | characters. If Source and Destination overlap, then the results are\r | |
85 | undefined.\r | |
86 | \r | |
87 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
88 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
89 | If Length > 0 and Source is NULL, then ASSERT().\r | |
77f863ee | 90 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r |
e1f414b6 | 91 | If Source and Destination overlap, then ASSERT().\r |
53e96610 | 92 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than \r |
93 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
e1f414b6 | 94 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r |
dfbe9de9 | 95 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r |
53e96610 | 96 | then ASSERT().\r |
e1f414b6 | 97 | \r |
127010dd | 98 | @param Destination A pointer to a Null-terminated Unicode string.\r |
99 | @param Source A pointer to a Null-terminated Unicode string.\r | |
2fc59a00 | 100 | @param Length The maximum number of Unicode characters to copy.\r |
e1f414b6 | 101 | \r |
9aa049d9 | 102 | @return Destination.\r |
e1f414b6 | 103 | \r |
104 | **/\r | |
105 | CHAR16 *\r | |
106 | EFIAPI\r | |
107 | StrnCpy (\r | |
108 | OUT CHAR16 *Destination,\r | |
109 | IN CONST CHAR16 *Source,\r | |
110 | IN UINTN Length\r | |
111 | )\r | |
112 | {\r | |
113 | CHAR16 *ReturnValue;\r | |
114 | \r | |
115 | if (Length == 0) {\r | |
116 | return Destination;\r | |
117 | }\r | |
118 | \r | |
119 | //\r | |
120 | // Destination cannot be NULL if Length is not zero\r | |
121 | //\r | |
122 | ASSERT (Destination != NULL);\r | |
24dcb5e5 | 123 | ASSERT (((UINTN) Destination & BIT0) == 0);\r |
e1f414b6 | 124 | \r |
125 | //\r | |
126 | // Destination and source cannot overlap\r | |
e1f414b6 | 127 | //\r |
128 | ASSERT ((UINTN)(Destination - Source) > StrLen (Source));\r | |
129 | ASSERT ((UINTN)(Source - Destination) >= Length);\r | |
130 | \r | |
dfbe9de9 | 131 | if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) {\r |
132 | ASSERT (Length <= PcdGet32 (PcdMaximumUnicodeStringLength));\r | |
133 | }\r | |
134 | \r | |
e1f414b6 | 135 | ReturnValue = Destination;\r |
136 | \r | |
137 | while ((*Source != L'\0') && (Length > 0)) {\r | |
138 | *(Destination++) = *(Source++);\r | |
139 | Length--;\r | |
140 | }\r | |
141 | \r | |
142 | ZeroMem (Destination, Length * sizeof (*Destination));\r | |
143 | return ReturnValue;\r | |
144 | }\r | |
1bb390f1 | 145 | #endif\r |
e1f414b6 | 146 | \r |
147 | /**\r | |
148 | Returns the length of a Null-terminated Unicode string.\r | |
149 | \r | |
150 | This function returns the number of Unicode characters in the Null-terminated\r | |
151 | Unicode string specified by String.\r | |
152 | \r | |
153 | If String is NULL, then ASSERT().\r | |
154 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
155 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
dfbe9de9 | 156 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
e1f414b6 | 157 | Null-terminator, then ASSERT().\r |
158 | \r | |
127010dd | 159 | @param String A pointer to a Null-terminated Unicode string.\r |
e1f414b6 | 160 | \r |
161 | @return The length of String.\r | |
162 | \r | |
163 | **/\r | |
164 | UINTN\r | |
165 | EFIAPI\r | |
166 | StrLen (\r | |
167 | IN CONST CHAR16 *String\r | |
168 | )\r | |
169 | {\r | |
170 | UINTN Length;\r | |
171 | \r | |
172 | ASSERT (String != NULL);\r | |
24dcb5e5 | 173 | ASSERT (((UINTN) String & BIT0) == 0);\r |
e1f414b6 | 174 | \r |
175 | for (Length = 0; *String != L'\0'; String++, Length++) {\r | |
176 | //\r | |
177 | // If PcdMaximumUnicodeStringLength is not zero,\r | |
178 | // length should not more than PcdMaximumUnicodeStringLength\r | |
179 | //\r | |
180 | if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) {\r | |
181 | ASSERT (Length < PcdGet32 (PcdMaximumUnicodeStringLength));\r | |
182 | }\r | |
183 | }\r | |
184 | return Length;\r | |
185 | }\r | |
186 | \r | |
187 | /**\r | |
188 | Returns the size of a Null-terminated Unicode string in bytes, including the\r | |
189 | Null terminator.\r | |
190 | \r | |
9aa049d9 | 191 | This function returns the size, in bytes, of the Null-terminated Unicode string \r |
192 | specified by String.\r | |
e1f414b6 | 193 | \r |
194 | If String is NULL, then ASSERT().\r | |
195 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
196 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
dfbe9de9 | 197 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
e1f414b6 | 198 | Null-terminator, then ASSERT().\r |
199 | \r | |
127010dd | 200 | @param String A pointer to a Null-terminated Unicode string.\r |
e1f414b6 | 201 | \r |
9aa049d9 | 202 | @return The size of String.\r |
e1f414b6 | 203 | \r |
204 | **/\r | |
205 | UINTN\r | |
206 | EFIAPI\r | |
207 | StrSize (\r | |
208 | IN CONST CHAR16 *String\r | |
209 | )\r | |
210 | {\r | |
211 | return (StrLen (String) + 1) * sizeof (*String);\r | |
212 | }\r | |
213 | \r | |
214 | /**\r | |
215 | Compares two Null-terminated Unicode strings, and returns the difference\r | |
216 | between the first mismatched Unicode characters.\r | |
217 | \r | |
218 | This function compares the Null-terminated Unicode string FirstString to the\r | |
219 | Null-terminated Unicode string SecondString. If FirstString is identical to\r | |
220 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
221 | mismatched Unicode character in SecondString subtracted from the first\r | |
222 | mismatched Unicode character in FirstString.\r | |
223 | \r | |
224 | If FirstString is NULL, then ASSERT().\r | |
225 | If FirstString is not aligned on a 16-bit boundary, then ASSERT().\r | |
226 | If SecondString is NULL, then ASSERT().\r | |
227 | If SecondString is not aligned on a 16-bit boundary, then ASSERT().\r | |
228 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r | |
dfbe9de9 | 229 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
e1f414b6 | 230 | Null-terminator, then ASSERT().\r |
231 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r | |
dfbe9de9 | 232 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
e1f414b6 | 233 | Null-terminator, then ASSERT().\r |
234 | \r | |
127010dd | 235 | @param FirstString A pointer to a Null-terminated Unicode string.\r |
236 | @param SecondString A pointer to a Null-terminated Unicode string.\r | |
e1f414b6 | 237 | \r |
1106ffe1 | 238 | @retval 0 FirstString is identical to SecondString.\r |
9aa049d9 | 239 | @return others FirstString is not identical to SecondString.\r |
e1f414b6 | 240 | \r |
241 | **/\r | |
242 | INTN\r | |
243 | EFIAPI\r | |
244 | StrCmp (\r | |
245 | IN CONST CHAR16 *FirstString,\r | |
246 | IN CONST CHAR16 *SecondString\r | |
247 | )\r | |
248 | {\r | |
249 | //\r | |
250 | // ASSERT both strings are less long than PcdMaximumUnicodeStringLength\r | |
251 | //\r | |
252 | ASSERT (StrSize (FirstString) != 0);\r | |
253 | ASSERT (StrSize (SecondString) != 0);\r | |
254 | \r | |
255 | while ((*FirstString != L'\0') && (*FirstString == *SecondString)) {\r | |
256 | FirstString++;\r | |
257 | SecondString++;\r | |
258 | }\r | |
259 | return *FirstString - *SecondString;\r | |
260 | }\r | |
261 | \r | |
262 | /**\r | |
9aa049d9 | 263 | Compares up to a specified length the contents of two Null-terminated Unicode strings,\r |
264 | and returns the difference between the first mismatched Unicode characters.\r | |
2fc60b70 | 265 | \r |
e1f414b6 | 266 | This function compares the Null-terminated Unicode string FirstString to the\r |
267 | Null-terminated Unicode string SecondString. At most, Length Unicode\r | |
268 | characters will be compared. If Length is 0, then 0 is returned. If\r | |
269 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
270 | value returned is the first mismatched Unicode character in SecondString\r | |
271 | subtracted from the first mismatched Unicode character in FirstString.\r | |
272 | \r | |
273 | If Length > 0 and FirstString is NULL, then ASSERT().\r | |
77f863ee | 274 | If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().\r |
e1f414b6 | 275 | If Length > 0 and SecondString is NULL, then ASSERT().\r |
77f863ee | 276 | If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().\r |
53e96610 | 277 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than\r |
278 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
279 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than\r | |
280 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
281 | then ASSERT().\r | |
282 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than\r | |
283 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
dfbe9de9 | 284 | then ASSERT().\r |
e1f414b6 | 285 | \r |
127010dd | 286 | @param FirstString A pointer to a Null-terminated Unicode string.\r |
287 | @param SecondString A pointer to a Null-terminated Unicode string.\r | |
2fc59a00 | 288 | @param Length The maximum number of Unicode characters to compare.\r |
e1f414b6 | 289 | \r |
1106ffe1 | 290 | @retval 0 FirstString is identical to SecondString.\r |
9aa049d9 | 291 | @return others FirstString is not identical to SecondString.\r |
e1f414b6 | 292 | \r |
293 | **/\r | |
294 | INTN\r | |
295 | EFIAPI\r | |
296 | StrnCmp (\r | |
297 | IN CONST CHAR16 *FirstString,\r | |
298 | IN CONST CHAR16 *SecondString,\r | |
299 | IN UINTN Length\r | |
300 | )\r | |
301 | {\r | |
2bfb6009 | 302 | if (Length == 0) {\r |
e1f414b6 | 303 | return 0;\r |
304 | }\r | |
305 | \r | |
306 | //\r | |
307 | // ASSERT both strings are less long than PcdMaximumUnicodeStringLength.\r | |
308 | // Length tests are performed inside StrLen().\r | |
309 | //\r | |
310 | ASSERT (StrSize (FirstString) != 0);\r | |
311 | ASSERT (StrSize (SecondString) != 0);\r | |
312 | \r | |
dfbe9de9 | 313 | if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) {\r |
314 | ASSERT (Length <= PcdGet32 (PcdMaximumUnicodeStringLength));\r | |
315 | }\r | |
316 | \r | |
e1f414b6 | 317 | while ((*FirstString != L'\0') &&\r |
753a18f9 | 318 | (*SecondString != L'\0') &&\r |
e1f414b6 | 319 | (*FirstString == *SecondString) &&\r |
320 | (Length > 1)) {\r | |
321 | FirstString++;\r | |
322 | SecondString++;\r | |
323 | Length--;\r | |
324 | }\r | |
325 | \r | |
326 | return *FirstString - *SecondString;\r | |
327 | }\r | |
328 | \r | |
1bb390f1 ED |
329 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
330 | \r | |
e1f414b6 | 331 | /**\r |
1bb390f1 ED |
332 | [ATTENTION] This function will be deprecated for security reason.\r |
333 | \r | |
e1f414b6 | 334 | Concatenates one Null-terminated Unicode string to another Null-terminated\r |
335 | Unicode string, and returns the concatenated Unicode string.\r | |
336 | \r | |
337 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
338 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
339 | Null-terminated Unicode string Destination. The Null-terminated concatenated\r | |
340 | Unicode String is returned. If Source and Destination overlap, then the\r | |
341 | results are undefined.\r | |
342 | \r | |
343 | If Destination is NULL, then ASSERT().\r | |
77f863ee | 344 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
e1f414b6 | 345 | If Source is NULL, then ASSERT().\r |
77f863ee | 346 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r |
e1f414b6 | 347 | If Source and Destination overlap, then ASSERT().\r |
348 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r | |
dfbe9de9 | 349 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
e1f414b6 | 350 | Null-terminator, then ASSERT().\r |
351 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
dfbe9de9 | 352 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
e1f414b6 | 353 | Null-terminator, then ASSERT().\r |
354 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
355 | and Source results in a Unicode string with more than\r | |
dfbe9de9 | 356 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
e1f414b6 | 357 | Null-terminator, then ASSERT().\r |
358 | \r | |
127010dd | 359 | @param Destination A pointer to a Null-terminated Unicode string.\r |
360 | @param Source A pointer to a Null-terminated Unicode string.\r | |
e1f414b6 | 361 | \r |
9aa049d9 | 362 | @return Destination.\r |
e1f414b6 | 363 | \r |
364 | **/\r | |
365 | CHAR16 *\r | |
366 | EFIAPI\r | |
367 | StrCat (\r | |
368 | IN OUT CHAR16 *Destination,\r | |
369 | IN CONST CHAR16 *Source\r | |
370 | )\r | |
371 | {\r | |
372 | StrCpy (Destination + StrLen (Destination), Source);\r | |
373 | \r | |
374 | //\r | |
375 | // Size of the resulting string should never be zero.\r | |
376 | // PcdMaximumUnicodeStringLength is tested inside StrLen().\r | |
377 | //\r | |
378 | ASSERT (StrSize (Destination) != 0);\r | |
379 | return Destination;\r | |
380 | }\r | |
381 | \r | |
382 | /**\r | |
1bb390f1 ED |
383 | [ATTENTION] This function will be deprecated for security reason.\r |
384 | \r | |
9aa049d9 | 385 | Concatenates up to a specified length one Null-terminated Unicode to the end \r |
386 | of another Null-terminated Unicode string, and returns the concatenated \r | |
e1f414b6 | 387 | Unicode string.\r |
388 | \r | |
389 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
390 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
391 | Null-terminated Unicode string Destination, and Destination is returned. At\r | |
392 | most, Length Unicode characters are concatenated from Source to the end of\r | |
393 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
394 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
395 | the results are undefined.\r | |
396 | \r | |
397 | If Destination is NULL, then ASSERT().\r | |
398 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
399 | If Length > 0 and Source is NULL, then ASSERT().\r | |
400 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
401 | If Source and Destination overlap, then ASSERT().\r | |
53e96610 | 402 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than \r |
403 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
e1f414b6 | 404 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r |
dfbe9de9 | 405 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
e1f414b6 | 406 | Null-terminator, then ASSERT().\r |
407 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
dfbe9de9 | 408 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
e1f414b6 | 409 | Null-terminator, then ASSERT().\r |
410 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
53e96610 | 411 | and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength\r |
412 | Unicode characters, not including the Null-terminator, then ASSERT().\r | |
e1f414b6 | 413 | \r |
127010dd | 414 | @param Destination A pointer to a Null-terminated Unicode string.\r |
415 | @param Source A pointer to a Null-terminated Unicode string.\r | |
2fc59a00 | 416 | @param Length The maximum number of Unicode characters to concatenate from\r |
e1f414b6 | 417 | Source.\r |
418 | \r | |
9aa049d9 | 419 | @return Destination.\r |
e1f414b6 | 420 | \r |
421 | **/\r | |
422 | CHAR16 *\r | |
423 | EFIAPI\r | |
424 | StrnCat (\r | |
425 | IN OUT CHAR16 *Destination,\r | |
426 | IN CONST CHAR16 *Source,\r | |
427 | IN UINTN Length\r | |
428 | )\r | |
429 | {\r | |
8f635c36 | 430 | UINTN DestinationLen;\r |
431 | \r | |
432 | DestinationLen = StrLen (Destination);\r | |
433 | StrnCpy (Destination + DestinationLen, Source, Length);\r | |
434 | Destination[DestinationLen + Length] = L'\0';\r | |
e1f414b6 | 435 | \r |
436 | //\r | |
437 | // Size of the resulting string should never be zero.\r | |
438 | // PcdMaximumUnicodeStringLength is tested inside StrLen().\r | |
439 | //\r | |
440 | ASSERT (StrSize (Destination) != 0);\r | |
441 | return Destination;\r | |
442 | }\r | |
1bb390f1 | 443 | #endif\r |
e1f414b6 | 444 | \r |
445 | /**\r | |
9aa049d9 | 446 | Returns the first occurrence of a Null-terminated Unicode sub-string\r |
e1f414b6 | 447 | in a Null-terminated Unicode string.\r |
448 | \r | |
9aa049d9 | 449 | This function scans the contents of the Null-terminated Unicode string\r |
450 | specified by String and returns the first occurrence of SearchString.\r | |
451 | If SearchString is not found in String, then NULL is returned. If\r | |
452 | the length of SearchString is zero, then String is\r | |
e1f414b6 | 453 | returned.\r |
9aa049d9 | 454 | \r |
e1f414b6 | 455 | If String is NULL, then ASSERT().\r |
456 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
457 | If SearchString is NULL, then ASSERT().\r | |
458 | If SearchString is not aligned on a 16-bit boundary, then ASSERT().\r | |
459 | \r | |
9aa049d9 | 460 | If PcdMaximumUnicodeStringLength is not zero, and SearchString\r |
461 | or String contains more than PcdMaximumUnicodeStringLength Unicode\r | |
dfbe9de9 | 462 | characters, not including the Null-terminator, then ASSERT().\r |
e1f414b6 | 463 | \r |
127010dd | 464 | @param String A pointer to a Null-terminated Unicode string.\r |
465 | @param SearchString A pointer to a Null-terminated Unicode string to search for.\r | |
e1f414b6 | 466 | \r |
9aa049d9 | 467 | @retval NULL If the SearchString does not appear in String.\r |
468 | @return others If there is a match.\r | |
e1f414b6 | 469 | \r |
470 | **/\r | |
471 | CHAR16 *\r | |
472 | EFIAPI\r | |
473 | StrStr (\r | |
2fc60b70 | 474 | IN CONST CHAR16 *String,\r |
475 | IN CONST CHAR16 *SearchString\r | |
e1f414b6 | 476 | )\r |
477 | {\r | |
478 | CONST CHAR16 *FirstMatch;\r | |
479 | CONST CHAR16 *SearchStringTmp;\r | |
480 | \r | |
e1f414b6 | 481 | //\r |
4df26661 | 482 | // ASSERT both strings are less long than PcdMaximumUnicodeStringLength.\r |
483 | // Length tests are performed inside StrLen().\r | |
e1f414b6 | 484 | //\r |
4df26661 | 485 | ASSERT (StrSize (String) != 0);\r |
486 | ASSERT (StrSize (SearchString) != 0);\r | |
e1f414b6 | 487 | \r |
62e71e2f | 488 | if (*SearchString == L'\0') {\r |
faeb3214 | 489 | return (CHAR16 *) String;\r |
62e71e2f | 490 | }\r |
491 | \r | |
492 | while (*String != L'\0') {\r | |
e1f414b6 | 493 | SearchStringTmp = SearchString;\r |
494 | FirstMatch = String;\r | |
495 | \r | |
496 | while ((*String == *SearchStringTmp) \r | |
62e71e2f | 497 | && (*String != L'\0')) {\r |
e1f414b6 | 498 | String++;\r |
499 | SearchStringTmp++;\r | |
500 | } \r | |
501 | \r | |
62e71e2f | 502 | if (*SearchStringTmp == L'\0') {\r |
e1f414b6 | 503 | return (CHAR16 *) FirstMatch;\r |
504 | }\r | |
505 | \r | |
62e71e2f | 506 | if (*String == L'\0') {\r |
507 | return NULL;\r | |
e1f414b6 | 508 | }\r |
62e71e2f | 509 | \r |
510 | String = FirstMatch + 1;\r | |
e1f414b6 | 511 | }\r |
512 | \r | |
513 | return NULL;\r | |
514 | }\r | |
515 | \r | |
516 | /**\r | |
517 | Check if a Unicode character is a decimal character.\r | |
518 | \r | |
519 | This internal function checks if a Unicode character is a \r | |
520 | decimal character. The valid decimal character is from\r | |
521 | L'0' to L'9'.\r | |
522 | \r | |
e1f414b6 | 523 | @param Char The character to check against.\r |
524 | \r | |
525 | @retval TRUE If the Char is a decmial character.\r | |
24dcb5e5 | 526 | @retval FALSE If the Char is not a decmial character.\r |
e1f414b6 | 527 | \r |
528 | **/\r | |
e1f414b6 | 529 | BOOLEAN\r |
42eedea9 | 530 | EFIAPI\r |
e1f414b6 | 531 | InternalIsDecimalDigitCharacter (\r |
532 | IN CHAR16 Char\r | |
533 | )\r | |
534 | {\r | |
535 | return (BOOLEAN) (Char >= L'0' && Char <= L'9');\r | |
536 | }\r | |
537 | \r | |
538 | /**\r | |
539 | Convert a Unicode character to upper case only if \r | |
540 | it maps to a valid small-case ASCII character.\r | |
541 | \r | |
542 | This internal function only deal with Unicode character\r | |
24dcb5e5 | 543 | which maps to a valid small-case ASCII character, i.e.\r |
e1f414b6 | 544 | L'a' to L'z'. For other Unicode character, the input character\r |
545 | is returned directly.\r | |
546 | \r | |
e1f414b6 | 547 | @param Char The character to convert.\r |
548 | \r | |
549 | @retval LowerCharacter If the Char is with range L'a' to L'z'.\r | |
550 | @retval Unchanged Otherwise.\r | |
551 | \r | |
552 | **/\r | |
e1f414b6 | 553 | CHAR16\r |
42eedea9 | 554 | EFIAPI\r |
e1f414b6 | 555 | InternalCharToUpper (\r |
556 | IN CHAR16 Char\r | |
557 | )\r | |
558 | {\r | |
559 | if (Char >= L'a' && Char <= L'z') {\r | |
560 | return (CHAR16) (Char - (L'a' - L'A'));\r | |
561 | }\r | |
562 | \r | |
563 | return Char;\r | |
564 | }\r | |
565 | \r | |
566 | /**\r | |
567 | Convert a Unicode character to numerical value.\r | |
568 | \r | |
569 | This internal function only deal with Unicode character\r | |
570 | which maps to a valid hexadecimal ASII character, i.e.\r | |
571 | L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other \r | |
572 | Unicode character, the value returned does not make sense.\r | |
573 | \r | |
574 | @param Char The character to convert.\r | |
575 | \r | |
24dcb5e5 | 576 | @return The numerical value converted.\r |
e1f414b6 | 577 | \r |
578 | **/\r | |
e1f414b6 | 579 | UINTN\r |
42eedea9 | 580 | EFIAPI\r |
e1f414b6 | 581 | InternalHexCharToUintn (\r |
582 | IN CHAR16 Char\r | |
583 | )\r | |
584 | {\r | |
585 | if (InternalIsDecimalDigitCharacter (Char)) {\r | |
586 | return Char - L'0';\r | |
587 | }\r | |
588 | \r | |
95ba3d92 | 589 | return (10 + InternalCharToUpper (Char) - L'A');\r |
e1f414b6 | 590 | }\r |
591 | \r | |
592 | /**\r | |
593 | Check if a Unicode character is a hexadecimal character.\r | |
594 | \r | |
595 | This internal function checks if a Unicode character is a \r | |
596 | decimal character. The valid hexadecimal character is \r | |
597 | L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r | |
598 | \r | |
599 | \r | |
600 | @param Char The character to check against.\r | |
601 | \r | |
602 | @retval TRUE If the Char is a hexadecmial character.\r | |
24dcb5e5 | 603 | @retval FALSE If the Char is not a hexadecmial character.\r |
e1f414b6 | 604 | \r |
605 | **/\r | |
e1f414b6 | 606 | BOOLEAN\r |
42eedea9 | 607 | EFIAPI\r |
e1f414b6 | 608 | InternalIsHexaDecimalDigitCharacter (\r |
609 | IN CHAR16 Char\r | |
610 | )\r | |
611 | {\r | |
612 | \r | |
613 | return (BOOLEAN) (InternalIsDecimalDigitCharacter (Char) ||\r | |
614 | (Char >= L'A' && Char <= L'F') ||\r | |
615 | (Char >= L'a' && Char <= L'f'));\r | |
616 | }\r | |
617 | \r | |
618 | /**\r | |
9aa049d9 | 619 | Convert a Null-terminated Unicode decimal string to a value of\r |
e1f414b6 | 620 | type UINTN.\r |
621 | \r | |
9aa049d9 | 622 | This function returns a value of type UINTN by interpreting the contents\r |
623 | of the Unicode string specified by String as a decimal number. The format\r | |
e1f414b6 | 624 | of the input Unicode string String is:\r |
9aa049d9 | 625 | \r |
2fe241a2 | 626 | [spaces] [decimal digits].\r |
9aa049d9 | 627 | \r |
628 | The valid decimal digit character is in the range [0-9]. The\r | |
629 | function will ignore the pad space, which includes spaces or\r | |
630 | tab characters, before [decimal digits]. The running zero in the\r | |
631 | beginning of [decimal digits] will be ignored. Then, the function\r | |
632 | stops at the first character that is a not a valid decimal character\r | |
633 | or a Null-terminator, whichever one comes first.\r | |
634 | \r | |
e1f414b6 | 635 | If String is NULL, then ASSERT().\r |
9aa049d9 | 636 | If String is not aligned in a 16-bit boundary, then ASSERT().\r |
e1f414b6 | 637 | If String has only pad spaces, then 0 is returned.\r |
9aa049d9 | 638 | If String has no pad spaces or valid decimal digits,\r |
e1f414b6 | 639 | then 0 is returned.\r |
9aa049d9 | 640 | If the number represented by String overflows according\r |
ea2e0921 | 641 | to the range defined by UINTN, then MAX_UINTN is returned.\r |
9aa049d9 | 642 | \r |
643 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
dfbe9de9 | 644 | more than PcdMaximumUnicodeStringLength Unicode characters, not including\r |
e1f414b6 | 645 | the Null-terminator, then ASSERT().\r |
646 | \r | |
127010dd | 647 | @param String A pointer to a Null-terminated Unicode string.\r |
e1f414b6 | 648 | \r |
9aa049d9 | 649 | @retval Value translated from String.\r |
e1f414b6 | 650 | \r |
651 | **/\r | |
652 | UINTN\r | |
653 | EFIAPI\r | |
654 | StrDecimalToUintn (\r | |
2fc60b70 | 655 | IN CONST CHAR16 *String\r |
e1f414b6 | 656 | )\r |
657 | {\r | |
658 | UINTN Result;\r | |
e1f414b6 | 659 | \r |
ea2e0921 | 660 | StrDecimalToUintnS (String, (CHAR16 **) NULL, &Result);\r |
e1f414b6 | 661 | return Result;\r |
662 | }\r | |
663 | \r | |
664 | \r | |
665 | /**\r | |
9aa049d9 | 666 | Convert a Null-terminated Unicode decimal string to a value of\r |
e1f414b6 | 667 | type UINT64.\r |
668 | \r | |
9aa049d9 | 669 | This function returns a value of type UINT64 by interpreting the contents\r |
670 | of the Unicode string specified by String as a decimal number. The format\r | |
e1f414b6 | 671 | of the input Unicode string String is:\r |
9aa049d9 | 672 | \r |
2fe241a2 | 673 | [spaces] [decimal digits].\r |
9aa049d9 | 674 | \r |
675 | The valid decimal digit character is in the range [0-9]. The\r | |
676 | function will ignore the pad space, which includes spaces or\r | |
677 | tab characters, before [decimal digits]. The running zero in the\r | |
678 | beginning of [decimal digits] will be ignored. Then, the function\r | |
679 | stops at the first character that is a not a valid decimal character\r | |
680 | or a Null-terminator, whichever one comes first.\r | |
681 | \r | |
e1f414b6 | 682 | If String is NULL, then ASSERT().\r |
9aa049d9 | 683 | If String is not aligned in a 16-bit boundary, then ASSERT().\r |
e1f414b6 | 684 | If String has only pad spaces, then 0 is returned.\r |
9aa049d9 | 685 | If String has no pad spaces or valid decimal digits,\r |
e1f414b6 | 686 | then 0 is returned.\r |
9aa049d9 | 687 | If the number represented by String overflows according\r |
ea2e0921 | 688 | to the range defined by UINT64, then MAX_UINT64 is returned.\r |
9aa049d9 | 689 | \r |
690 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
dfbe9de9 | 691 | more than PcdMaximumUnicodeStringLength Unicode characters, not including\r |
e1f414b6 | 692 | the Null-terminator, then ASSERT().\r |
693 | \r | |
127010dd | 694 | @param String A pointer to a Null-terminated Unicode string.\r |
e1f414b6 | 695 | \r |
9aa049d9 | 696 | @retval Value translated from String.\r |
e1f414b6 | 697 | \r |
698 | **/\r | |
699 | UINT64\r | |
700 | EFIAPI\r | |
701 | StrDecimalToUint64 (\r | |
2fc60b70 | 702 | IN CONST CHAR16 *String\r |
e1f414b6 | 703 | )\r |
704 | {\r | |
705 | UINT64 Result;\r | |
706 | \r | |
ea2e0921 | 707 | StrDecimalToUint64S (String, (CHAR16 **) NULL, &Result);\r |
e1f414b6 | 708 | return Result;\r |
709 | }\r | |
710 | \r | |
711 | /**\r | |
712 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.\r | |
713 | \r | |
9aa049d9 | 714 | This function returns a value of type UINTN by interpreting the contents\r |
715 | of the Unicode string specified by String as a hexadecimal number.\r | |
e1f414b6 | 716 | The format of the input Unicode string String is:\r |
9aa049d9 | 717 | \r |
718 | [spaces][zeros][x][hexadecimal digits].\r | |
719 | \r | |
720 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
721 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
722 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
723 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
724 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
725 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
726 | first valid hexadecimal digit. Then, the function stops at the first character that is\r | |
e1f414b6 | 727 | a not a valid hexadecimal character or NULL, whichever one comes first.\r |
728 | \r | |
729 | If String is NULL, then ASSERT().\r | |
730 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
731 | If String has only pad spaces, then zero is returned.\r | |
9aa049d9 | 732 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r |
e1f414b6 | 733 | then zero is returned.\r |
9aa049d9 | 734 | If the number represented by String overflows according to the range defined by\r |
ea2e0921 | 735 | UINTN, then MAX_UINTN is returned.\r |
e1f414b6 | 736 | \r |
9aa049d9 | 737 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r |
dfbe9de9 | 738 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r |
e1f414b6 | 739 | then ASSERT().\r |
740 | \r | |
127010dd | 741 | @param String A pointer to a Null-terminated Unicode string.\r |
e1f414b6 | 742 | \r |
9aa049d9 | 743 | @retval Value translated from String.\r |
e1f414b6 | 744 | \r |
745 | **/\r | |
746 | UINTN\r | |
747 | EFIAPI\r | |
748 | StrHexToUintn (\r | |
2fc60b70 | 749 | IN CONST CHAR16 *String\r |
e1f414b6 | 750 | )\r |
751 | {\r | |
752 | UINTN Result;\r | |
753 | \r | |
ea2e0921 | 754 | StrHexToUintnS (String, (CHAR16 **) NULL, &Result);\r |
e1f414b6 | 755 | return Result;\r |
756 | }\r | |
757 | \r | |
758 | \r | |
759 | /**\r | |
760 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.\r | |
761 | \r | |
9aa049d9 | 762 | This function returns a value of type UINT64 by interpreting the contents\r |
763 | of the Unicode string specified by String as a hexadecimal number.\r | |
764 | The format of the input Unicode string String is\r | |
765 | \r | |
766 | [spaces][zeros][x][hexadecimal digits].\r | |
767 | \r | |
768 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
769 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
770 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
771 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
772 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
773 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
774 | first valid hexadecimal digit. Then, the function stops at the first character that is\r | |
e1f414b6 | 775 | a not a valid hexadecimal character or NULL, whichever one comes first.\r |
776 | \r | |
777 | If String is NULL, then ASSERT().\r | |
778 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
779 | If String has only pad spaces, then zero is returned.\r | |
9aa049d9 | 780 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r |
e1f414b6 | 781 | then zero is returned.\r |
9aa049d9 | 782 | If the number represented by String overflows according to the range defined by\r |
ea2e0921 | 783 | UINT64, then MAX_UINT64 is returned.\r |
e1f414b6 | 784 | \r |
9aa049d9 | 785 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r |
dfbe9de9 | 786 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r |
e1f414b6 | 787 | then ASSERT().\r |
788 | \r | |
127010dd | 789 | @param String A pointer to a Null-terminated Unicode string.\r |
e1f414b6 | 790 | \r |
9aa049d9 | 791 | @retval Value translated from String.\r |
e1f414b6 | 792 | \r |
2fc60b70 | 793 | **/\r |
e1f414b6 | 794 | UINT64\r |
795 | EFIAPI\r | |
796 | StrHexToUint64 (\r | |
2fc60b70 | 797 | IN CONST CHAR16 *String\r |
e1f414b6 | 798 | )\r |
799 | {\r | |
800 | UINT64 Result;\r | |
801 | \r | |
ea2e0921 | 802 | StrHexToUint64S (String, (CHAR16 **) NULL, &Result);\r |
e1f414b6 | 803 | return Result;\r |
804 | }\r | |
805 | \r | |
806 | /**\r | |
807 | Check if a ASCII character is a decimal character.\r | |
808 | \r | |
809 | This internal function checks if a Unicode character is a \r | |
810 | decimal character. The valid decimal character is from\r | |
811 | '0' to '9'.\r | |
812 | \r | |
813 | @param Char The character to check against.\r | |
814 | \r | |
815 | @retval TRUE If the Char is a decmial character.\r | |
24dcb5e5 | 816 | @retval FALSE If the Char is not a decmial character.\r |
e1f414b6 | 817 | \r |
818 | **/\r | |
e1f414b6 | 819 | BOOLEAN\r |
42eedea9 | 820 | EFIAPI\r |
e1f414b6 | 821 | InternalAsciiIsDecimalDigitCharacter (\r |
822 | IN CHAR8 Char\r | |
823 | )\r | |
824 | {\r | |
825 | return (BOOLEAN) (Char >= '0' && Char <= '9');\r | |
826 | }\r | |
827 | \r | |
828 | /**\r | |
829 | Check if a ASCII character is a hexadecimal character.\r | |
830 | \r | |
831 | This internal function checks if a ASCII character is a \r | |
832 | decimal character. The valid hexadecimal character is \r | |
833 | L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r | |
834 | \r | |
835 | \r | |
836 | @param Char The character to check against.\r | |
837 | \r | |
838 | @retval TRUE If the Char is a hexadecmial character.\r | |
24dcb5e5 | 839 | @retval FALSE If the Char is not a hexadecmial character.\r |
e1f414b6 | 840 | \r |
841 | **/\r | |
e1f414b6 | 842 | BOOLEAN\r |
42eedea9 | 843 | EFIAPI\r |
e1f414b6 | 844 | InternalAsciiIsHexaDecimalDigitCharacter (\r |
845 | IN CHAR8 Char\r | |
846 | )\r | |
847 | {\r | |
848 | \r | |
849 | return (BOOLEAN) (InternalAsciiIsDecimalDigitCharacter (Char) ||\r | |
850 | (Char >= 'A' && Char <= 'F') ||\r | |
851 | (Char >= 'a' && Char <= 'f'));\r | |
852 | }\r | |
853 | \r | |
415aa2f1 SZ |
854 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
855 | \r | |
e1f414b6 | 856 | /**\r |
415aa2f1 SZ |
857 | [ATTENTION] This function is deprecated for security reason.\r |
858 | \r | |
9aa049d9 | 859 | Convert a Null-terminated Unicode string to a Null-terminated\r |
e1f414b6 | 860 | ASCII string and returns the ASCII string.\r |
9aa049d9 | 861 | \r |
862 | This function converts the content of the Unicode string Source\r | |
863 | to the ASCII string Destination by copying the lower 8 bits of\r | |
864 | each Unicode character. It returns Destination.\r | |
865 | \r | |
d3e0289c | 866 | The caller is responsible to make sure Destination points to a buffer with size\r |
867 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r | |
868 | \r | |
9aa049d9 | 869 | If any Unicode characters in Source contain non-zero value in\r |
870 | the upper 8 bits, then ASSERT().\r | |
e1f414b6 | 871 | \r |
872 | If Destination is NULL, then ASSERT().\r | |
873 | If Source is NULL, then ASSERT().\r | |
874 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
875 | If Source and Destination overlap, then ASSERT().\r | |
876 | \r | |
9aa049d9 | 877 | If PcdMaximumUnicodeStringLength is not zero, and Source contains\r |
dfbe9de9 | 878 | more than PcdMaximumUnicodeStringLength Unicode characters, not including\r |
e1f414b6 | 879 | the Null-terminator, then ASSERT().\r |
9aa049d9 | 880 | \r |
881 | If PcdMaximumAsciiStringLength is not zero, and Source contains more\r | |
dfbe9de9 | 882 | than PcdMaximumAsciiStringLength Unicode characters, not including the\r |
e1f414b6 | 883 | Null-terminator, then ASSERT().\r |
884 | \r | |
127010dd | 885 | @param Source A pointer to a Null-terminated Unicode string.\r |
886 | @param Destination A pointer to a Null-terminated ASCII string.\r | |
e1f414b6 | 887 | \r |
9aa049d9 | 888 | @return Destination.\r |
e1f414b6 | 889 | \r |
890 | **/\r | |
891 | CHAR8 *\r | |
892 | EFIAPI\r | |
893 | UnicodeStrToAsciiStr (\r | |
2fc60b70 | 894 | IN CONST CHAR16 *Source,\r |
895 | OUT CHAR8 *Destination\r | |
e1f414b6 | 896 | )\r |
897 | {\r | |
4df26661 | 898 | CHAR8 *ReturnValue;\r |
899 | \r | |
e1f414b6 | 900 | ASSERT (Destination != NULL);\r |
4df26661 | 901 | \r |
902 | //\r | |
903 | // ASSERT if Source is long than PcdMaximumUnicodeStringLength.\r | |
904 | // Length tests are performed inside StrLen().\r | |
905 | //\r | |
906 | ASSERT (StrSize (Source) != 0);\r | |
e1f414b6 | 907 | \r |
908 | //\r | |
909 | // Source and Destination should not overlap\r | |
910 | //\r | |
d52b9d86 | 911 | ASSERT ((UINTN) (Destination - (CHAR8 *) Source) >= StrSize (Source));\r |
e1f414b6 | 912 | ASSERT ((UINTN) ((CHAR8 *) Source - Destination) > StrLen (Source));\r |
913 | \r | |
e1f414b6 | 914 | \r |
4df26661 | 915 | ReturnValue = Destination;\r |
e1f414b6 | 916 | while (*Source != '\0') {\r |
917 | //\r | |
918 | // If any Unicode characters in Source contain \r | |
919 | // non-zero value in the upper 8 bits, then ASSERT().\r | |
920 | //\r | |
921 | ASSERT (*Source < 0x100);\r | |
922 | *(Destination++) = (CHAR8) *(Source++);\r | |
923 | }\r | |
924 | \r | |
925 | *Destination = '\0';\r | |
4df26661 | 926 | \r |
927 | //\r | |
928 | // ASSERT Original Destination is less long than PcdMaximumAsciiStringLength.\r | |
929 | // Length tests are performed inside AsciiStrLen().\r | |
930 | //\r | |
931 | ASSERT (AsciiStrSize (ReturnValue) != 0);\r | |
932 | \r | |
933 | return ReturnValue;\r | |
e1f414b6 | 934 | }\r |
935 | \r | |
e1f414b6 | 936 | /**\r |
1bb390f1 ED |
937 | [ATTENTION] This function will be deprecated for security reason.\r |
938 | \r | |
e1f414b6 | 939 | Copies one Null-terminated ASCII string to another Null-terminated ASCII\r |
940 | string and returns the new ASCII string.\r | |
941 | \r | |
942 | This function copies the contents of the ASCII string Source to the ASCII\r | |
943 | string Destination, and returns Destination. If Source and Destination\r | |
944 | overlap, then the results are undefined.\r | |
945 | \r | |
946 | If Destination is NULL, then ASSERT().\r | |
947 | If Source is NULL, then ASSERT().\r | |
948 | If Source and Destination overlap, then ASSERT().\r | |
949 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
dfbe9de9 | 950 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
e1f414b6 | 951 | then ASSERT().\r |
952 | \r | |
127010dd | 953 | @param Destination A pointer to a Null-terminated ASCII string.\r |
954 | @param Source A pointer to a Null-terminated ASCII string.\r | |
e1f414b6 | 955 | \r |
9aa049d9 | 956 | @return Destination\r |
e1f414b6 | 957 | \r |
958 | **/\r | |
959 | CHAR8 *\r | |
960 | EFIAPI\r | |
961 | AsciiStrCpy (\r | |
962 | OUT CHAR8 *Destination,\r | |
963 | IN CONST CHAR8 *Source\r | |
964 | )\r | |
965 | {\r | |
966 | CHAR8 *ReturnValue;\r | |
967 | \r | |
968 | //\r | |
969 | // Destination cannot be NULL\r | |
970 | //\r | |
971 | ASSERT (Destination != NULL);\r | |
972 | \r | |
973 | //\r | |
974 | // Destination and source cannot overlap\r | |
975 | //\r | |
976 | ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));\r | |
977 | ASSERT ((UINTN)(Source - Destination) > AsciiStrLen (Source));\r | |
978 | \r | |
979 | ReturnValue = Destination;\r | |
42eedea9 | 980 | while (*Source != 0) {\r |
e1f414b6 | 981 | *(Destination++) = *(Source++);\r |
982 | }\r | |
983 | *Destination = 0;\r | |
984 | return ReturnValue;\r | |
985 | }\r | |
986 | \r | |
987 | /**\r | |
1bb390f1 ED |
988 | [ATTENTION] This function will be deprecated for security reason.\r |
989 | \r | |
9aa049d9 | 990 | Copies up to a specified length one Null-terminated ASCII string to another \r |
991 | Null-terminated ASCII string and returns the new ASCII string.\r | |
e1f414b6 | 992 | \r |
993 | This function copies the contents of the ASCII string Source to the ASCII\r | |
994 | string Destination, and returns Destination. At most, Length ASCII characters\r | |
995 | are copied from Source to Destination. If Length is 0, then Destination is\r | |
996 | returned unmodified. If Length is greater that the number of ASCII characters\r | |
997 | in Source, then Destination is padded with Null ASCII characters. If Source\r | |
998 | and Destination overlap, then the results are undefined.\r | |
999 | \r | |
1000 | If Destination is NULL, then ASSERT().\r | |
1001 | If Source is NULL, then ASSERT().\r | |
1002 | If Source and Destination overlap, then ASSERT().\r | |
53e96610 | 1003 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than \r |
1004 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
e1f414b6 | 1005 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r |
dfbe9de9 | 1006 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
53e96610 | 1007 | then ASSERT().\r |
e1f414b6 | 1008 | \r |
127010dd | 1009 | @param Destination A pointer to a Null-terminated ASCII string.\r |
1010 | @param Source A pointer to a Null-terminated ASCII string.\r | |
2fc59a00 | 1011 | @param Length The maximum number of ASCII characters to copy.\r |
e1f414b6 | 1012 | \r |
9aa049d9 | 1013 | @return Destination\r |
e1f414b6 | 1014 | \r |
1015 | **/\r | |
1016 | CHAR8 *\r | |
1017 | EFIAPI\r | |
1018 | AsciiStrnCpy (\r | |
1019 | OUT CHAR8 *Destination,\r | |
1020 | IN CONST CHAR8 *Source,\r | |
1021 | IN UINTN Length\r | |
1022 | )\r | |
1023 | {\r | |
1024 | CHAR8 *ReturnValue;\r | |
1025 | \r | |
2bfb6009 | 1026 | if (Length == 0) {\r |
e1f414b6 | 1027 | return Destination;\r |
1028 | }\r | |
1029 | \r | |
1030 | //\r | |
1031 | // Destination cannot be NULL\r | |
1032 | //\r | |
1033 | ASSERT (Destination != NULL);\r | |
1034 | \r | |
1035 | //\r | |
1036 | // Destination and source cannot overlap\r | |
1037 | //\r | |
1038 | ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));\r | |
1039 | ASSERT ((UINTN)(Source - Destination) >= Length);\r | |
1040 | \r | |
dfbe9de9 | 1041 | if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {\r |
1042 | ASSERT (Length <= PcdGet32 (PcdMaximumAsciiStringLength));\r | |
1043 | }\r | |
1044 | \r | |
e1f414b6 | 1045 | ReturnValue = Destination;\r |
1046 | \r | |
42eedea9 | 1047 | while (*Source != 0 && Length > 0) {\r |
e1f414b6 | 1048 | *(Destination++) = *(Source++);\r |
1049 | Length--;\r | |
1050 | }\r | |
1051 | \r | |
1052 | ZeroMem (Destination, Length * sizeof (*Destination));\r | |
1053 | return ReturnValue;\r | |
1054 | }\r | |
1bb390f1 | 1055 | #endif\r |
e1f414b6 | 1056 | \r |
1057 | /**\r | |
1058 | Returns the length of a Null-terminated ASCII string.\r | |
1059 | \r | |
1060 | This function returns the number of ASCII characters in the Null-terminated\r | |
1061 | ASCII string specified by String.\r | |
1062 | \r | |
9aa049d9 | 1063 | If Length > 0 and Destination is NULL, then ASSERT().\r |
1064 | If Length > 0 and Source is NULL, then ASSERT().\r | |
e1f414b6 | 1065 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r |
dfbe9de9 | 1066 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
e1f414b6 | 1067 | then ASSERT().\r |
1068 | \r | |
127010dd | 1069 | @param String A pointer to a Null-terminated ASCII string.\r |
e1f414b6 | 1070 | \r |
1071 | @return The length of String.\r | |
1072 | \r | |
1073 | **/\r | |
1074 | UINTN\r | |
1075 | EFIAPI\r | |
1076 | AsciiStrLen (\r | |
1077 | IN CONST CHAR8 *String\r | |
1078 | )\r | |
1079 | {\r | |
1080 | UINTN Length;\r | |
1081 | \r | |
1082 | ASSERT (String != NULL);\r | |
1083 | \r | |
1084 | for (Length = 0; *String != '\0'; String++, Length++) {\r | |
1085 | //\r | |
1086 | // If PcdMaximumUnicodeStringLength is not zero,\r | |
1087 | // length should not more than PcdMaximumUnicodeStringLength\r | |
1088 | //\r | |
1089 | if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {\r | |
1090 | ASSERT (Length < PcdGet32 (PcdMaximumAsciiStringLength));\r | |
1091 | }\r | |
1092 | }\r | |
1093 | return Length;\r | |
1094 | }\r | |
1095 | \r | |
1096 | /**\r | |
1097 | Returns the size of a Null-terminated ASCII string in bytes, including the\r | |
1098 | Null terminator.\r | |
1099 | \r | |
1100 | This function returns the size, in bytes, of the Null-terminated ASCII string\r | |
1101 | specified by String.\r | |
1102 | \r | |
1103 | If String is NULL, then ASSERT().\r | |
1104 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
dfbe9de9 | 1105 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
e1f414b6 | 1106 | then ASSERT().\r |
1107 | \r | |
127010dd | 1108 | @param String A pointer to a Null-terminated ASCII string.\r |
e1f414b6 | 1109 | \r |
1110 | @return The size of String.\r | |
1111 | \r | |
1112 | **/\r | |
1113 | UINTN\r | |
1114 | EFIAPI\r | |
1115 | AsciiStrSize (\r | |
1116 | IN CONST CHAR8 *String\r | |
1117 | )\r | |
1118 | {\r | |
1119 | return (AsciiStrLen (String) + 1) * sizeof (*String);\r | |
1120 | }\r | |
1121 | \r | |
1122 | /**\r | |
1123 | Compares two Null-terminated ASCII strings, and returns the difference\r | |
1124 | between the first mismatched ASCII characters.\r | |
1125 | \r | |
1126 | This function compares the Null-terminated ASCII string FirstString to the\r | |
1127 | Null-terminated ASCII string SecondString. If FirstString is identical to\r | |
1128 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
1129 | mismatched ASCII character in SecondString subtracted from the first\r | |
1130 | mismatched ASCII character in FirstString.\r | |
1131 | \r | |
1132 | If FirstString is NULL, then ASSERT().\r | |
1133 | If SecondString is NULL, then ASSERT().\r | |
1134 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
dfbe9de9 | 1135 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
e1f414b6 | 1136 | then ASSERT().\r |
1137 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
dfbe9de9 | 1138 | than PcdMaximumAsciiStringLength ASCII characters, not including the\r |
e1f414b6 | 1139 | Null-terminator, then ASSERT().\r |
1140 | \r | |
127010dd | 1141 | @param FirstString A pointer to a Null-terminated ASCII string.\r |
1142 | @param SecondString A pointer to a Null-terminated ASCII string.\r | |
e1f414b6 | 1143 | \r |
9aa049d9 | 1144 | @retval ==0 FirstString is identical to SecondString.\r |
1145 | @retval !=0 FirstString is not identical to SecondString.\r | |
e1f414b6 | 1146 | \r |
1147 | **/\r | |
1148 | INTN\r | |
1149 | EFIAPI\r | |
1150 | AsciiStrCmp (\r | |
1151 | IN CONST CHAR8 *FirstString,\r | |
1152 | IN CONST CHAR8 *SecondString\r | |
1153 | )\r | |
1154 | {\r | |
1155 | //\r | |
1156 | // ASSERT both strings are less long than PcdMaximumAsciiStringLength\r | |
1157 | //\r | |
1158 | ASSERT (AsciiStrSize (FirstString));\r | |
1159 | ASSERT (AsciiStrSize (SecondString));\r | |
1160 | \r | |
1161 | while ((*FirstString != '\0') && (*FirstString == *SecondString)) {\r | |
1162 | FirstString++;\r | |
1163 | SecondString++;\r | |
1164 | }\r | |
1165 | \r | |
1166 | return *FirstString - *SecondString;\r | |
1167 | }\r | |
1168 | \r | |
1169 | /**\r | |
24dcb5e5 | 1170 | Converts a lowercase Ascii character to upper one.\r |
e1f414b6 | 1171 | \r |
1172 | If Chr is lowercase Ascii character, then converts it to upper one.\r | |
1173 | \r | |
1174 | If Value >= 0xA0, then ASSERT().\r | |
1175 | If (Value & 0x0F) >= 0x0A, then ASSERT().\r | |
1176 | \r | |
42eedea9 | 1177 | @param Chr one Ascii character\r |
e1f414b6 | 1178 | \r |
1179 | @return The uppercase value of Ascii character \r | |
1180 | \r | |
1181 | **/\r | |
e1f414b6 | 1182 | CHAR8\r |
42eedea9 | 1183 | EFIAPI\r |
80151e53 | 1184 | InternalBaseLibAsciiToUpper (\r |
e1f414b6 | 1185 | IN CHAR8 Chr\r |
1186 | )\r | |
1187 | {\r | |
1188 | return (UINT8) ((Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr);\r | |
1189 | }\r | |
1190 | \r | |
1191 | /**\r | |
1192 | Convert a ASCII character to numerical value.\r | |
1193 | \r | |
1194 | This internal function only deal with Unicode character\r | |
1195 | which maps to a valid hexadecimal ASII character, i.e.\r | |
1196 | '0' to '9', 'a' to 'f' or 'A' to 'F'. For other \r | |
1197 | ASCII character, the value returned does not make sense.\r | |
1198 | \r | |
1199 | @param Char The character to convert.\r | |
1200 | \r | |
24dcb5e5 | 1201 | @return The numerical value converted.\r |
e1f414b6 | 1202 | \r |
1203 | **/\r | |
e1f414b6 | 1204 | UINTN\r |
42eedea9 | 1205 | EFIAPI\r |
e1f414b6 | 1206 | InternalAsciiHexCharToUintn (\r |
1207 | IN CHAR8 Char\r | |
1208 | )\r | |
1209 | {\r | |
1210 | if (InternalIsDecimalDigitCharacter (Char)) {\r | |
1211 | return Char - '0';\r | |
1212 | }\r | |
1213 | \r | |
95ba3d92 | 1214 | return (10 + InternalBaseLibAsciiToUpper (Char) - 'A');\r |
e1f414b6 | 1215 | }\r |
1216 | \r | |
1217 | \r | |
1218 | /**\r | |
1219 | Performs a case insensitive comparison of two Null-terminated ASCII strings,\r | |
1220 | and returns the difference between the first mismatched ASCII characters.\r | |
1221 | \r | |
1222 | This function performs a case insensitive comparison of the Null-terminated\r | |
1223 | ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r | |
1224 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
1225 | value returned is the first mismatched lower case ASCII character in\r | |
1226 | SecondString subtracted from the first mismatched lower case ASCII character\r | |
1227 | in FirstString.\r | |
1228 | \r | |
1229 | If FirstString is NULL, then ASSERT().\r | |
1230 | If SecondString is NULL, then ASSERT().\r | |
1231 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
dfbe9de9 | 1232 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
e1f414b6 | 1233 | then ASSERT().\r |
1234 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
dfbe9de9 | 1235 | than PcdMaximumAsciiStringLength ASCII characters, not including the\r |
e1f414b6 | 1236 | Null-terminator, then ASSERT().\r |
1237 | \r | |
127010dd | 1238 | @param FirstString A pointer to a Null-terminated ASCII string.\r |
1239 | @param SecondString A pointer to a Null-terminated ASCII string.\r | |
e1f414b6 | 1240 | \r |
9aa049d9 | 1241 | @retval ==0 FirstString is identical to SecondString using case insensitive\r |
1106ffe1 | 1242 | comparisons.\r |
9aa049d9 | 1243 | @retval !=0 FirstString is not identical to SecondString using case\r |
1244 | insensitive comparisons.\r | |
e1f414b6 | 1245 | \r |
1246 | **/\r | |
1247 | INTN\r | |
1248 | EFIAPI\r | |
1249 | AsciiStriCmp (\r | |
1250 | IN CONST CHAR8 *FirstString,\r | |
1251 | IN CONST CHAR8 *SecondString\r | |
1252 | )\r | |
1253 | {\r | |
1254 | CHAR8 UpperFirstString;\r | |
1255 | CHAR8 UpperSecondString;\r | |
1256 | \r | |
1257 | //\r | |
1258 | // ASSERT both strings are less long than PcdMaximumAsciiStringLength\r | |
1259 | //\r | |
1260 | ASSERT (AsciiStrSize (FirstString));\r | |
1261 | ASSERT (AsciiStrSize (SecondString));\r | |
1262 | \r | |
80151e53 LG |
1263 | UpperFirstString = InternalBaseLibAsciiToUpper (*FirstString);\r |
1264 | UpperSecondString = InternalBaseLibAsciiToUpper (*SecondString);\r | |
e1f414b6 | 1265 | while ((*FirstString != '\0') && (UpperFirstString == UpperSecondString)) {\r |
1266 | FirstString++;\r | |
1267 | SecondString++;\r | |
80151e53 LG |
1268 | UpperFirstString = InternalBaseLibAsciiToUpper (*FirstString);\r |
1269 | UpperSecondString = InternalBaseLibAsciiToUpper (*SecondString);\r | |
e1f414b6 | 1270 | }\r |
1271 | \r | |
1272 | return UpperFirstString - UpperSecondString;\r | |
1273 | }\r | |
1274 | \r | |
1275 | /**\r | |
1276 | Compares two Null-terminated ASCII strings with maximum lengths, and returns\r | |
1277 | the difference between the first mismatched ASCII characters.\r | |
1278 | \r | |
1279 | This function compares the Null-terminated ASCII string FirstString to the\r | |
1280 | Null-terminated ASCII string SecondString. At most, Length ASCII characters\r | |
1281 | will be compared. If Length is 0, then 0 is returned. If FirstString is\r | |
1282 | identical to SecondString, then 0 is returned. Otherwise, the value returned\r | |
1283 | is the first mismatched ASCII character in SecondString subtracted from the\r | |
1284 | first mismatched ASCII character in FirstString.\r | |
1285 | \r | |
9aa049d9 | 1286 | If Length > 0 and FirstString is NULL, then ASSERT().\r |
1287 | If Length > 0 and SecondString is NULL, then ASSERT().\r | |
53e96610 | 1288 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than \r |
1289 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
1290 | If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than\r | |
dfbe9de9 | 1291 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
e1f414b6 | 1292 | then ASSERT().\r |
53e96610 | 1293 | If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than\r |
dfbe9de9 | 1294 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
53e96610 | 1295 | then ASSERT().\r |
e1f414b6 | 1296 | \r |
127010dd | 1297 | @param FirstString A pointer to a Null-terminated ASCII string.\r |
1298 | @param SecondString A pointer to a Null-terminated ASCII string.\r | |
2fc59a00 | 1299 | @param Length The maximum number of ASCII characters for compare.\r |
2fc60b70 | 1300 | \r |
9aa049d9 | 1301 | @retval ==0 FirstString is identical to SecondString.\r |
1302 | @retval !=0 FirstString is not identical to SecondString.\r | |
e1f414b6 | 1303 | \r |
1304 | **/\r | |
1305 | INTN\r | |
1306 | EFIAPI\r | |
1307 | AsciiStrnCmp (\r | |
1308 | IN CONST CHAR8 *FirstString,\r | |
1309 | IN CONST CHAR8 *SecondString,\r | |
1310 | IN UINTN Length\r | |
1311 | )\r | |
1312 | {\r | |
2bfb6009 | 1313 | if (Length == 0) {\r |
e1f414b6 | 1314 | return 0;\r |
1315 | }\r | |
1316 | \r | |
1317 | //\r | |
1318 | // ASSERT both strings are less long than PcdMaximumAsciiStringLength\r | |
1319 | //\r | |
1320 | ASSERT (AsciiStrSize (FirstString));\r | |
1321 | ASSERT (AsciiStrSize (SecondString));\r | |
1322 | \r | |
dfbe9de9 | 1323 | if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {\r |
1324 | ASSERT (Length <= PcdGet32 (PcdMaximumAsciiStringLength));\r | |
1325 | }\r | |
1326 | \r | |
e1f414b6 | 1327 | while ((*FirstString != '\0') &&\r |
753a18f9 | 1328 | (*SecondString != '\0') &&\r |
e1f414b6 | 1329 | (*FirstString == *SecondString) &&\r |
1330 | (Length > 1)) {\r | |
1331 | FirstString++;\r | |
1332 | SecondString++;\r | |
1333 | Length--;\r | |
1334 | }\r | |
1335 | return *FirstString - *SecondString;\r | |
1336 | }\r | |
1337 | \r | |
1bb390f1 ED |
1338 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
1339 | \r | |
e1f414b6 | 1340 | /**\r |
1bb390f1 ED |
1341 | [ATTENTION] This function will be deprecated for security reason.\r |
1342 | \r | |
e1f414b6 | 1343 | Concatenates one Null-terminated ASCII string to another Null-terminated\r |
1344 | ASCII string, and returns the concatenated ASCII string.\r | |
1345 | \r | |
1346 | This function concatenates two Null-terminated ASCII strings. The contents of\r | |
1347 | Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
1348 | terminated ASCII string Destination. The Null-terminated concatenated ASCII\r | |
1349 | String is returned.\r | |
1350 | \r | |
1351 | If Destination is NULL, then ASSERT().\r | |
1352 | If Source is NULL, then ASSERT().\r | |
1353 | If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r | |
dfbe9de9 | 1354 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
e1f414b6 | 1355 | then ASSERT().\r |
1356 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
dfbe9de9 | 1357 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
e1f414b6 | 1358 | then ASSERT().\r |
1359 | If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r | |
1360 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
1361 | ASCII characters, then ASSERT().\r | |
1362 | \r | |
127010dd | 1363 | @param Destination A pointer to a Null-terminated ASCII string.\r |
1364 | @param Source A pointer to a Null-terminated ASCII string.\r | |
e1f414b6 | 1365 | \r |
9aa049d9 | 1366 | @return Destination\r |
e1f414b6 | 1367 | \r |
1368 | **/\r | |
1369 | CHAR8 *\r | |
1370 | EFIAPI\r | |
1371 | AsciiStrCat (\r | |
1372 | IN OUT CHAR8 *Destination,\r | |
1373 | IN CONST CHAR8 *Source\r | |
1374 | )\r | |
1375 | {\r | |
1376 | AsciiStrCpy (Destination + AsciiStrLen (Destination), Source);\r | |
1377 | \r | |
1378 | //\r | |
1379 | // Size of the resulting string should never be zero.\r | |
1380 | // PcdMaximumUnicodeStringLength is tested inside StrLen().\r | |
1381 | //\r | |
1382 | ASSERT (AsciiStrSize (Destination) != 0);\r | |
1383 | return Destination;\r | |
1384 | }\r | |
1385 | \r | |
1386 | /**\r | |
1bb390f1 ED |
1387 | [ATTENTION] This function will be deprecated for security reason.\r |
1388 | \r | |
9aa049d9 | 1389 | Concatenates up to a specified length one Null-terminated ASCII string to \r |
1390 | the end of another Null-terminated ASCII string, and returns the \r | |
1391 | concatenated ASCII string.\r | |
e1f414b6 | 1392 | \r |
1393 | This function concatenates two Null-terminated ASCII strings. The contents\r | |
1394 | of Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
1395 | terminated ASCII string Destination, and Destination is returned. At most,\r | |
1396 | Length ASCII characters are concatenated from Source to the end of\r | |
1397 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
1398 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
1399 | the results are undefined.\r | |
1400 | \r | |
9aa049d9 | 1401 | If Length > 0 and Destination is NULL, then ASSERT().\r |
1402 | If Length > 0 and Source is NULL, then ASSERT().\r | |
e1f414b6 | 1403 | If Source and Destination overlap, then ASSERT().\r |
53e96610 | 1404 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than\r |
1405 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
e1f414b6 | 1406 | If PcdMaximumAsciiStringLength is not zero, and Destination contains more than\r |
dfbe9de9 | 1407 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
e1f414b6 | 1408 | then ASSERT().\r |
1409 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r | |
dfbe9de9 | 1410 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
e1f414b6 | 1411 | then ASSERT().\r |
1412 | If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r | |
1413 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
53e96610 | 1414 | ASCII characters, not including the Null-terminator, then ASSERT().\r |
e1f414b6 | 1415 | \r |
127010dd | 1416 | @param Destination A pointer to a Null-terminated ASCII string.\r |
1417 | @param Source A pointer to a Null-terminated ASCII string.\r | |
2fc59a00 | 1418 | @param Length The maximum number of ASCII characters to concatenate from\r |
e1f414b6 | 1419 | Source.\r |
1420 | \r | |
9aa049d9 | 1421 | @return Destination\r |
e1f414b6 | 1422 | \r |
1423 | **/\r | |
1424 | CHAR8 *\r | |
1425 | EFIAPI\r | |
1426 | AsciiStrnCat (\r | |
1427 | IN OUT CHAR8 *Destination,\r | |
1428 | IN CONST CHAR8 *Source,\r | |
1429 | IN UINTN Length\r | |
1430 | )\r | |
1431 | {\r | |
8f635c36 | 1432 | UINTN DestinationLen;\r |
1433 | \r | |
1434 | DestinationLen = AsciiStrLen (Destination);\r | |
1435 | AsciiStrnCpy (Destination + DestinationLen, Source, Length);\r | |
1436 | Destination[DestinationLen + Length] = '\0';\r | |
e1f414b6 | 1437 | \r |
1438 | //\r | |
1439 | // Size of the resulting string should never be zero.\r | |
1440 | // PcdMaximumUnicodeStringLength is tested inside StrLen().\r | |
1441 | //\r | |
1442 | ASSERT (AsciiStrSize (Destination) != 0);\r | |
1443 | return Destination;\r | |
1444 | }\r | |
1bb390f1 | 1445 | #endif\r |
e1f414b6 | 1446 | \r |
1447 | /**\r | |
9aa049d9 | 1448 | Returns the first occurrence of a Null-terminated ASCII sub-string\r |
e1f414b6 | 1449 | in a Null-terminated ASCII string.\r |
1450 | \r | |
9aa049d9 | 1451 | This function scans the contents of the ASCII string specified by String\r |
1452 | and returns the first occurrence of SearchString. If SearchString is not\r | |
1453 | found in String, then NULL is returned. If the length of SearchString is zero,\r | |
e1f414b6 | 1454 | then String is returned.\r |
9aa049d9 | 1455 | \r |
e1f414b6 | 1456 | If String is NULL, then ASSERT().\r |
1457 | If SearchString is NULL, then ASSERT().\r | |
1458 | \r | |
9aa049d9 | 1459 | If PcdMaximumAsciiStringLength is not zero, and SearchString or\r |
1460 | String contains more than PcdMaximumAsciiStringLength Unicode characters\r | |
e1f414b6 | 1461 | not including the Null-terminator, then ASSERT().\r |
1462 | \r | |
127010dd | 1463 | @param String A pointer to a Null-terminated ASCII string.\r |
1464 | @param SearchString A pointer to a Null-terminated ASCII string to search for.\r | |
e1f414b6 | 1465 | \r |
1466 | @retval NULL If the SearchString does not appear in String.\r | |
9aa049d9 | 1467 | @retval others If there is a match return the first occurrence of SearchingString.\r |
1468 | If the length of SearchString is zero,return String.\r | |
e1f414b6 | 1469 | \r |
1470 | **/\r | |
1471 | CHAR8 *\r | |
1472 | EFIAPI\r | |
1473 | AsciiStrStr (\r | |
2fc60b70 | 1474 | IN CONST CHAR8 *String,\r |
1475 | IN CONST CHAR8 *SearchString\r | |
e1f414b6 | 1476 | )\r |
1477 | {\r | |
1478 | CONST CHAR8 *FirstMatch;\r | |
1479 | CONST CHAR8 *SearchStringTmp;\r | |
1480 | \r | |
e1f414b6 | 1481 | //\r |
4df26661 | 1482 | // ASSERT both strings are less long than PcdMaximumAsciiStringLength\r |
e1f414b6 | 1483 | //\r |
4df26661 | 1484 | ASSERT (AsciiStrSize (String) != 0);\r |
1485 | ASSERT (AsciiStrSize (SearchString) != 0);\r | |
e1f414b6 | 1486 | \r |
62e71e2f | 1487 | if (*SearchString == '\0') {\r |
faeb3214 | 1488 | return (CHAR8 *) String;\r |
62e71e2f | 1489 | }\r |
1490 | \r | |
e1f414b6 | 1491 | while (*String != '\0') {\r |
1492 | SearchStringTmp = SearchString;\r | |
1493 | FirstMatch = String;\r | |
1494 | \r | |
1495 | while ((*String == *SearchStringTmp) \r | |
e1f414b6 | 1496 | && (*String != '\0')) {\r |
1497 | String++;\r | |
1498 | SearchStringTmp++;\r | |
1499 | } \r | |
1500 | \r | |
1501 | if (*SearchStringTmp == '\0') {\r | |
1502 | return (CHAR8 *) FirstMatch;\r | |
1503 | }\r | |
1504 | \r | |
62e71e2f | 1505 | if (*String == '\0') {\r |
1506 | return NULL;\r | |
e1f414b6 | 1507 | }\r |
1508 | \r | |
62e71e2f | 1509 | String = FirstMatch + 1;\r |
e1f414b6 | 1510 | }\r |
1511 | \r | |
1512 | return NULL;\r | |
1513 | }\r | |
1514 | \r | |
1515 | /**\r | |
9aa049d9 | 1516 | Convert a Null-terminated ASCII decimal string to a value of type\r |
e1f414b6 | 1517 | UINTN.\r |
1518 | \r | |
9aa049d9 | 1519 | This function returns a value of type UINTN by interpreting the contents\r |
1520 | of the ASCII string String as a decimal number. The format of the input\r | |
e1f414b6 | 1521 | ASCII string String is:\r |
9aa049d9 | 1522 | \r |
e1f414b6 | 1523 | [spaces] [decimal digits].\r |
9aa049d9 | 1524 | \r |
1525 | The valid decimal digit character is in the range [0-9]. The function will\r | |
1526 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
1527 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
1528 | function stops at the first character that is a not a valid decimal character or\r | |
e1f414b6 | 1529 | Null-terminator, whichever on comes first.\r |
9aa049d9 | 1530 | \r |
e1f414b6 | 1531 | If String has only pad spaces, then 0 is returned.\r |
1532 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
9aa049d9 | 1533 | If the number represented by String overflows according to the range defined by\r |
ea2e0921 | 1534 | UINTN, then MAX_UINTN is returned.\r |
e1f414b6 | 1535 | If String is NULL, then ASSERT().\r |
9aa049d9 | 1536 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r |
1537 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
e1f414b6 | 1538 | then ASSERT().\r |
1539 | \r | |
127010dd | 1540 | @param String A pointer to a Null-terminated ASCII string.\r |
e1f414b6 | 1541 | \r |
9aa049d9 | 1542 | @retval Value translated from String.\r |
e1f414b6 | 1543 | \r |
1544 | **/\r | |
1545 | UINTN\r | |
1546 | EFIAPI\r | |
1547 | AsciiStrDecimalToUintn (\r | |
4df26661 | 1548 | IN CONST CHAR8 *String\r |
e1f414b6 | 1549 | )\r |
1550 | {\r | |
1551 | UINTN Result;\r | |
1552 | \r | |
ea2e0921 | 1553 | AsciiStrDecimalToUintnS (String, (CHAR8 **) NULL, &Result);\r |
e1f414b6 | 1554 | return Result;\r |
1555 | }\r | |
1556 | \r | |
1557 | \r | |
1558 | /**\r | |
9aa049d9 | 1559 | Convert a Null-terminated ASCII decimal string to a value of type\r |
e1f414b6 | 1560 | UINT64.\r |
1561 | \r | |
9aa049d9 | 1562 | This function returns a value of type UINT64 by interpreting the contents\r |
1563 | of the ASCII string String as a decimal number. The format of the input\r | |
e1f414b6 | 1564 | ASCII string String is:\r |
9aa049d9 | 1565 | \r |
e1f414b6 | 1566 | [spaces] [decimal digits].\r |
9aa049d9 | 1567 | \r |
1568 | The valid decimal digit character is in the range [0-9]. The function will\r | |
1569 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
1570 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
1571 | function stops at the first character that is a not a valid decimal character or\r | |
e1f414b6 | 1572 | Null-terminator, whichever on comes first.\r |
9aa049d9 | 1573 | \r |
e1f414b6 | 1574 | If String has only pad spaces, then 0 is returned.\r |
1575 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
9aa049d9 | 1576 | If the number represented by String overflows according to the range defined by\r |
ea2e0921 | 1577 | UINT64, then MAX_UINT64 is returned.\r |
e1f414b6 | 1578 | If String is NULL, then ASSERT().\r |
9aa049d9 | 1579 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r |
1580 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
e1f414b6 | 1581 | then ASSERT().\r |
1582 | \r | |
127010dd | 1583 | @param String A pointer to a Null-terminated ASCII string.\r |
e1f414b6 | 1584 | \r |
9aa049d9 | 1585 | @retval Value translated from String.\r |
e1f414b6 | 1586 | \r |
1587 | **/\r | |
1588 | UINT64\r | |
1589 | EFIAPI\r | |
1590 | AsciiStrDecimalToUint64 (\r | |
2fc60b70 | 1591 | IN CONST CHAR8 *String\r |
e1f414b6 | 1592 | )\r |
1593 | {\r | |
1594 | UINT64 Result;\r | |
1595 | \r | |
ea2e0921 | 1596 | AsciiStrDecimalToUint64S (String, (CHAR8 **) NULL, &Result);\r |
e1f414b6 | 1597 | return Result;\r |
1598 | }\r | |
1599 | \r | |
1600 | /**\r | |
1601 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.\r | |
1602 | \r | |
9aa049d9 | 1603 | This function returns a value of type UINTN by interpreting the contents of\r |
1604 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
e1f414b6 | 1605 | string String is:\r |
9aa049d9 | 1606 | \r |
e1f414b6 | 1607 | [spaces][zeros][x][hexadecimal digits].\r |
9aa049d9 | 1608 | \r |
1609 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1610 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
1611 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
1612 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
1613 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
1614 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
1615 | digit. Then, the function stops at the first character that is a not a valid\r | |
e1f414b6 | 1616 | hexadecimal character or Null-terminator, whichever on comes first.\r |
9aa049d9 | 1617 | \r |
e1f414b6 | 1618 | If String has only pad spaces, then 0 is returned.\r |
1619 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
1620 | 0 is returned.\r | |
1621 | \r | |
9aa049d9 | 1622 | If the number represented by String overflows according to the range defined by UINTN,\r |
ea2e0921 | 1623 | then MAX_UINTN is returned.\r |
e1f414b6 | 1624 | If String is NULL, then ASSERT().\r |
9aa049d9 | 1625 | If PcdMaximumAsciiStringLength is not zero,\r |
1626 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
e1f414b6 | 1627 | the Null-terminator, then ASSERT().\r |
1628 | \r | |
127010dd | 1629 | @param String A pointer to a Null-terminated ASCII string.\r |
e1f414b6 | 1630 | \r |
9aa049d9 | 1631 | @retval Value translated from String.\r |
e1f414b6 | 1632 | \r |
1633 | **/\r | |
1634 | UINTN\r | |
1635 | EFIAPI\r | |
1636 | AsciiStrHexToUintn (\r | |
2fc60b70 | 1637 | IN CONST CHAR8 *String\r |
e1f414b6 | 1638 | )\r |
1639 | {\r | |
1640 | UINTN Result;\r | |
1641 | \r | |
ea2e0921 | 1642 | AsciiStrHexToUintnS (String, (CHAR8 **) NULL, &Result);\r |
e1f414b6 | 1643 | return Result;\r |
1644 | }\r | |
1645 | \r | |
1646 | \r | |
1647 | /**\r | |
1648 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.\r | |
1649 | \r | |
9aa049d9 | 1650 | This function returns a value of type UINT64 by interpreting the contents of\r |
1651 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
e1f414b6 | 1652 | string String is:\r |
9aa049d9 | 1653 | \r |
e1f414b6 | 1654 | [spaces][zeros][x][hexadecimal digits].\r |
9aa049d9 | 1655 | \r |
1656 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1657 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
1658 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
1659 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
1660 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
1661 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
1662 | digit. Then, the function stops at the first character that is a not a valid\r | |
e1f414b6 | 1663 | hexadecimal character or Null-terminator, whichever on comes first.\r |
9aa049d9 | 1664 | \r |
e1f414b6 | 1665 | If String has only pad spaces, then 0 is returned.\r |
1666 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
1667 | 0 is returned.\r | |
1668 | \r | |
9aa049d9 | 1669 | If the number represented by String overflows according to the range defined by UINT64,\r |
ea2e0921 | 1670 | then MAX_UINT64 is returned.\r |
e1f414b6 | 1671 | If String is NULL, then ASSERT().\r |
9aa049d9 | 1672 | If PcdMaximumAsciiStringLength is not zero,\r |
1673 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
e1f414b6 | 1674 | the Null-terminator, then ASSERT().\r |
1675 | \r | |
127010dd | 1676 | @param String A pointer to a Null-terminated ASCII string.\r |
e1f414b6 | 1677 | \r |
9aa049d9 | 1678 | @retval Value translated from String.\r |
e1f414b6 | 1679 | \r |
1680 | **/\r | |
1681 | UINT64\r | |
1682 | EFIAPI\r | |
1683 | AsciiStrHexToUint64 (\r | |
2fc60b70 | 1684 | IN CONST CHAR8 *String\r |
e1f414b6 | 1685 | )\r |
1686 | {\r | |
1687 | UINT64 Result;\r | |
1688 | \r | |
ea2e0921 | 1689 | AsciiStrHexToUint64S (String, (CHAR8 **) NULL, &Result);\r |
e1f414b6 | 1690 | return Result;\r |
1691 | }\r | |
1692 | \r | |
415aa2f1 | 1693 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
e1f414b6 | 1694 | \r |
1695 | /**\r | |
415aa2f1 SZ |
1696 | [ATTENTION] This function is deprecated for security reason.\r |
1697 | \r | |
9aa049d9 | 1698 | Convert one Null-terminated ASCII string to a Null-terminated\r |
e1f414b6 | 1699 | Unicode string and returns the Unicode string.\r |
1700 | \r | |
9aa049d9 | 1701 | This function converts the contents of the ASCII string Source to the Unicode\r |
1702 | string Destination, and returns Destination. The function terminates the\r | |
1703 | Unicode string Destination by appending a Null-terminator character at the end.\r | |
1704 | The caller is responsible to make sure Destination points to a buffer with size\r | |
e1f414b6 | 1705 | equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r |
9aa049d9 | 1706 | \r |
e1f414b6 | 1707 | If Destination is NULL, then ASSERT().\r |
1708 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
1709 | If Source is NULL, then ASSERT().\r | |
1710 | If Source and Destination overlap, then ASSERT().\r | |
9aa049d9 | 1711 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r |
1712 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
e1f414b6 | 1713 | then ASSERT().\r |
9aa049d9 | 1714 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r |
1715 | PcdMaximumUnicodeStringLength ASCII characters not including the\r | |
e1f414b6 | 1716 | Null-terminator, then ASSERT().\r |
1717 | \r | |
127010dd | 1718 | @param Source A pointer to a Null-terminated ASCII string.\r |
1719 | @param Destination A pointer to a Null-terminated Unicode string.\r | |
e1f414b6 | 1720 | \r |
9aa049d9 | 1721 | @return Destination.\r |
e1f414b6 | 1722 | \r |
1723 | **/\r | |
1724 | CHAR16 *\r | |
1725 | EFIAPI\r | |
1726 | AsciiStrToUnicodeStr (\r | |
4df26661 | 1727 | IN CONST CHAR8 *Source,\r |
1728 | OUT CHAR16 *Destination\r | |
e1f414b6 | 1729 | )\r |
1730 | {\r | |
4df26661 | 1731 | CHAR16 *ReturnValue;\r |
1732 | \r | |
e1f414b6 | 1733 | ASSERT (Destination != NULL);\r |
e1f414b6 | 1734 | \r |
1735 | //\r | |
4df26661 | 1736 | // ASSERT Source is less long than PcdMaximumAsciiStringLength\r |
e1f414b6 | 1737 | //\r |
4df26661 | 1738 | ASSERT (AsciiStrSize (Source) != 0);\r |
e1f414b6 | 1739 | \r |
1740 | //\r | |
4df26661 | 1741 | // Source and Destination should not overlap\r |
e1f414b6 | 1742 | //\r |
4df26661 | 1743 | ASSERT ((UINTN) ((CHAR8 *) Destination - Source) > AsciiStrLen (Source));\r |
d52b9d86 SZ |
1744 | ASSERT ((UINTN) (Source - (CHAR8 *) Destination) >= (AsciiStrSize (Source) * sizeof (CHAR16)));\r |
1745 | \r | |
e1f414b6 | 1746 | \r |
4df26661 | 1747 | ReturnValue = Destination;\r |
e1f414b6 | 1748 | while (*Source != '\0') {\r |
1749 | *(Destination++) = (CHAR16) *(Source++);\r | |
1750 | }\r | |
1751 | //\r | |
1752 | // End the Destination with a NULL.\r | |
1753 | //\r | |
1754 | *Destination = '\0';\r | |
1755 | \r | |
4df26661 | 1756 | //\r |
1757 | // ASSERT Original Destination is less long than PcdMaximumUnicodeStringLength\r | |
1758 | //\r | |
1759 | ASSERT (StrSize (ReturnValue) != 0);\r | |
1760 | \r | |
1761 | return ReturnValue;\r | |
e1f414b6 | 1762 | }\r |
1763 | \r | |
415aa2f1 SZ |
1764 | #endif\r |
1765 | \r | |
e1f414b6 | 1766 | /**\r |
1767 | Converts an 8-bit value to an 8-bit BCD value.\r | |
1768 | \r | |
1769 | Converts the 8-bit value specified by Value to BCD. The BCD value is\r | |
1770 | returned.\r | |
1771 | \r | |
1772 | If Value >= 100, then ASSERT().\r | |
1773 | \r | |
1774 | @param Value The 8-bit value to convert to BCD. Range 0..99.\r | |
1775 | \r | |
9aa049d9 | 1776 | @return The BCD value.\r |
e1f414b6 | 1777 | \r |
1778 | **/\r | |
1779 | UINT8\r | |
1780 | EFIAPI\r | |
1781 | DecimalToBcd8 (\r | |
1782 | IN UINT8 Value\r | |
1783 | )\r | |
1784 | {\r | |
1785 | ASSERT (Value < 100);\r | |
1786 | return (UINT8) (((Value / 10) << 4) | (Value % 10));\r | |
1787 | }\r | |
1788 | \r | |
1789 | /**\r | |
1790 | Converts an 8-bit BCD value to an 8-bit value.\r | |
1791 | \r | |
1792 | Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r | |
1793 | value is returned.\r | |
1794 | \r | |
1795 | If Value >= 0xA0, then ASSERT().\r | |
1796 | If (Value & 0x0F) >= 0x0A, then ASSERT().\r | |
1797 | \r | |
1798 | @param Value The 8-bit BCD value to convert to an 8-bit value.\r | |
1799 | \r | |
9aa049d9 | 1800 | @return The 8-bit value is returned.\r |
e1f414b6 | 1801 | \r |
1802 | **/\r | |
1803 | UINT8\r | |
1804 | EFIAPI\r | |
1805 | BcdToDecimal8 (\r | |
1806 | IN UINT8 Value\r | |
1807 | )\r | |
1808 | {\r | |
1809 | ASSERT (Value < 0xa0);\r | |
1810 | ASSERT ((Value & 0xf) < 0xa);\r | |
1811 | return (UINT8) ((Value >> 4) * 10 + (Value & 0xf));\r | |
1812 | }\r |