* Tuples (,,,) are coded as Z3T
-* Alphabetic characters (upper and lower), digits, and '_'
+* Alphabetic characters (upper and lower) and digits
all translate to themselves;
except 'Z', which translates to 'ZZ'
and 'z', which translates to 'zz'
alreadyEncoded :: String -> Bool
alreadyEncoded s = all ok s
where
- ok '_' = True
ok ' ' = True -- This is a bit of a lie; if we really wanted spaces
-- in names we'd have to encode them. But we do put
-- spaces in ccall "occurrences", and we don't want to
str = _UNPK_ fast_str
unencodedChar :: Char -> Bool -- True for chars that don't need encoding
-unencodedChar '_' = True
unencodedChar 'Z' = False
unencodedChar 'z' = False
unencodedChar c = ISALPHANUM c
encode_ch 'z' = "zz"
encode_ch '&' = "za"
encode_ch '|' = "zb"
+encode_ch '^' = "zc"
encode_ch '$' = "zd"
encode_ch '=' = "ze"
encode_ch '>' = "zg"
encode_ch '\\' = "zr"
encode_ch '/' = "zs"
encode_ch '*' = "zt"
-encode_ch '^' = "zu"
+encode_ch '_' = "zu"
encode_ch '%' = "zv"
encode_ch c = ['z', 'x', intToDigit hi, intToDigit lo]
where