Mercurial > urweb
comparison src/prim.sml @ 1054:b06a2a65e670
UTF-8 in dynamic escaping
author | Adam Chlipala <adamc@hcoop.net> |
---|---|
date | Thu, 03 Dec 2009 11:50:51 -0500 |
parents | 4eb1c4a1b057 |
children | d7d5b167f267 |
comparison
equal
deleted
inserted
replaced
1053:4eb1c4a1b057 | 1054:b06a2a65e670 |
---|---|
72 if size s >= n then | 72 if size s >= n then |
73 s | 73 s |
74 else | 74 else |
75 str ch ^ pad (n-1, ch, s) | 75 str ch ^ pad (n-1, ch, s) |
76 | 76 |
77 val gccify = String.translate (fn ch => if Char.isPrint ch then | 77 val gccify = String.translate (fn ch => |
78 str ch | 78 case ch of |
79 else | 79 #"\"" => "\\\"" |
80 "\\" ^ pad (3, #"0", Int.fmt StringCvt.OCT (ord ch))) | 80 | #"\\" => "\\\\" |
81 | #"'" => "\\'" | |
82 | #"\n" => "\\n" | |
83 | #"\r" => "\\r" | |
84 | #"\t" => "\\t" | |
85 | #" " => " " | |
86 | _ => | |
87 if Char.isPrint ch then | |
88 str ch | |
89 else | |
90 "\\" ^ pad (3, #"0", Int.fmt StringCvt.OCT (ord ch))) | |
81 | 91 |
82 fun p_t_GCC t = | 92 fun p_t_GCC t = |
83 case t of | 93 case t of |
84 Int n => string (int2s n) | 94 Int n => string (int2s n) |
85 | Float n => string (float2s n) | 95 | Float n => string (float2s n) |