[Jprogramming] How to translate unicode into ANSI coding?
bill lam
bbill.lam at gmail.com
Mon Oct 23 00:35:44 HKT 2006
Gilles Kirouac wrote:
> In J601 WinXP:
>
> a.i.'é' NB. e + acute accent
> 195 169
>
> a.i.7 u: 'é'
> 233 NB. correct ANSI code for e acute
>
> a.i.7 u: 'àâèêéîïôûü'
> 224 226 232 234 233 238 239 244 251 252 NB.expected ANSI codes
>
> $7 u: 'é'
> 1 NB. expected
> 3!:0 ] 7 u: 'é'
> 131072 NB. translated, but still 2 bytes per char
>
> So I am using
>
> JtoANSI=: {&a.@:(a.&i.@:(7&u:"1))
>
> This appears ok for the french accentuated vowels of interest.
> Is it safe?
I'm not sure if code points are translated correctly for french, but you may use
1&u: to discard high byte from 2 byte unicodes. pls see u: documentation.
a.i. (1&u:)@(7&u:) 'àâèêéîïôûü'
224 226 232 234 233 238 239 244 251 252
3!:0 (1&u:)@(7&u:) 'àâèêéîïôûü'
2
--
regards,
bill
More information about the Programming
mailing list