Changeset 1c28ff5 in OpenModelica for OMCompiler/Compiler/Util/StringUtil.mo
- Timestamp:
- 2021-04-06T15:14:58+02:00 (3 years ago)
- Parents:
- f33851b5
- git-author:
- Martin Sjölund <martin@…> (03/16/21 08:57:25)
- git-committer:
- Martin Sjölund <martin@…> (04/06/21 15:14:58)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/Compiler/Util/StringUtil.mo
r83be5f2b r1c28ff5 387 387 end endsWithNewline; 388 388 389 function convertCharNonAsciiToHex "Converts a single character string to a hex representation if it is not valid unicode" 390 input output String s; 391 protected 392 Integer i; 393 constant String hex[:] = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"); 394 algorithm 395 i := stringCharInt(s); 396 if i < 128 then 397 return; 398 end if; 399 s := "0x" + hex[intDiv(i, 16)+1] + hex[intMod(i, 16)+1]; 400 end convertCharNonAsciiToHex; 401 402 function stripBOM 403 input output String s; 404 output String bom = ""; 405 algorithm 406 if stringLength(s) < 3 then 407 return; 408 end if; 409 if stringGet(s,1) == 239 and 410 stringGet(s,2) == 187 and 411 stringGet(s,3) == 191 then 412 s := substring(s, 4, stringLength(s)); 413 bom := substring(s, 1, 3); 414 end if; 415 end stripBOM; 416 389 417 annotation(__OpenModelica_Interface="util"); 390 418 end StringUtil;
Note: See TracChangeset
for help on using the changeset viewer.