Mercurial > urweb
comparison src/jscomp.sml @ 1285:514be09d5018
Better UTF-8 escaping for JavaScript and SQL literals
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Tue, 10 Aug 2010 15:55:43 -0400 |
parents | 003df929ee08 |
children | acabf3935060 |
comparison
equal
deleted
inserted
replaced
1284:43ca083678f8 | 1285:514be09d5018 |
---|---|
433 | #"\\" => "\\\\" | 433 | #"\\" => "\\\\" |
434 | #"\n" => "\\n" | 434 | #"\n" => "\\n" |
435 | #"\r" => "\\r" | 435 | #"\r" => "\\r" |
436 | #"\t" => "\\t" | 436 | #"\t" => "\\t" |
437 | ch => | 437 | ch => |
438 if Char.isPrint ch then | 438 if Char.isPrint ch orelse ord ch >= 128 then |
439 String.str ch | 439 String.str ch |
440 else | 440 else |
441 "\\" ^ padWith (#"0", | 441 "\\" ^ padWith (#"0", |
442 Int.fmt StringCvt.OCT (ord ch), | 442 Int.fmt StringCvt.OCT (ord ch), |
443 3) | 443 3) |