summaryrefslogtreecommitdiff
path: root/appl/lib/w3c
diff options
context:
space:
mode:
Diffstat (limited to 'appl/lib/w3c')
-rw-r--r--appl/lib/w3c/uris.b28
1 files changed, 17 insertions, 11 deletions
diff --git a/appl/lib/w3c/uris.b b/appl/lib/w3c/uris.b
index b49c17b8..07042dc4 100644
--- a/appl/lib/w3c/uris.b
+++ b/appl/lib/w3c/uris.b
@@ -260,20 +260,26 @@ dec(s: string): string
if(s[i] == '%' || s[i] == 0)
break;
}
- o := s[0:i];
+ t := s[0:i];
+ a := array[Sys->UTFmax*len s] of byte; # upper bound
+ o := 0;
while(i < len s){
- case c := s[i++] {
- '%' =>
- if((v := hex2(s[i:])) > 0){
- c = v;
- i += 2;
+ c := s[i++];
+ if(c < 16r80){
+ case c {
+ '%' =>
+ if((v := hex2(s[i:])) > 0){
+ c = v;
+ i += 2;
+ }
+ 0 =>
+ c = ' '; # shouldn't happen
}
- 0 =>
- c = ' '; # shouldn't happen
- }
- o[len o] = c;
+ a[o++] = byte c;
+ }else
+ o += sys->char2byte(c, a, o); # string contained Unicode
}
- return o;
+ return t + string a[0:o];
}
enc1(s: string, safe: string): string