Or,
   A{a.

   A{a.
鼠牛虎兔龍蛇馬羊猴鸡狗豬

I am not quite sure why u: does not handle A properly, but a
workaround there might be to manually convert to utf-16 which u: will
handle properly.

For example:

utf8to16=:3 :0
  if. 'literal'-: datatype y do. y=.a.i.y end.
  bits=.(8#2)#:y
  r=.''
  j=.0
  while.j<#y do.
    select. (j{bits)i.0
      case. 0 do.
        r=. r,j{y
        j=. j+1
      case. 2 do.
        r=. r,64#.((j+i.2){y)-192 128
        j=. j+2
      case. 3 do.
        r=. r,64#.((j+i.3){y)-224 128 128
        j=. j+3
      case. 4 do.
        r=. r,64#.((j+i.4){y)-240 128 128 128
        j=. j+4
      case. do. assert. 'invalid utf-8 argument'
    end.
  end.
  r
)

   u: utf8to16 A
鼠牛虎兔龍蛇馬羊猴鸡狗豬

But A{a. (or the equivalent {&a. A) is still simpler.

I hope this helps,

-- 
Raul

On Wed, Oct 18, 2017 at 1:46 PM, robert therriault
<[email protected]> wrote:
>
> Hi David,
>
> You can use {&a. to convert the encoded utf-8 into the characters
>
>    A=:  16be9 16bbc 16ba0 16be7 16b89 16b9b 16be8 16b99 16b8e
>    A=:A,16be5 16b85 16b94 16be9 16bbe 16b8d 16be8 16b9b 16b87
>    A=:  16be9 16bbc 16ba0 16be7 16b89 16b9b 16be8 16b99 16b8e
>    A=:A,16be5 16b85 16b94 16be9 16bbe 16b8d 16be8 16b9b 16b87
>    A=:A,16be9 16ba6 16bac 16be7 16bbe 16b8a 16be7 16b8c 16bb4
>    A=:A,16be9 16bb8 16ba1 16be7 16b8b 16b97 16be8 16bb1 16bac
>    A
> 233 188 160 231 137 155 232 153 142 229 133 148 233 190 141 232 155 135 233 
> 166 172 231 190 138 231 140 180 233 184 161 231 139 151 232 177 172
>    {&a. A
> 鼠牛虎兔龍蛇馬羊猴鸡狗豬
>
> Cheers, bob
>
>> On Oct 18, 2017, at 10:20 AM, David Lambert <[email protected]> wrote:
>>
>> How in j to have the characters display correctly?
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to