load 'data/odbc' Unicode not showing in terminal

30 views
Skip to first unread message

Michael Christodoulides

unread,
May 20, 2025, 7:57:38 AM5/20/25
to fo...@jsoftware.com
Hi,
I am a newbie to J,
I am considering using it to more easily interact to SQL Server.

Why is this not showing the output as unicode in terminal?

load 'data/odbc'
[ch=. ddcon 'Driver={ODBC Driver 17 for SQL
Server};Server=(localdb)\db1;Trusted_Connection=Yes'
ddfet ('select N''w こんにちは ''' ddsel ch), 1000
┌────────────┐
│w ?????
└────────────┘

Many thanks,

Michael

chris burke

unread,
May 20, 2025, 8:14:24 AM5/20/25
to fo...@jsoftware.com
In J, text is assumed to be in utf8 format. Try:

load 'unicode'
toutf8 each ddfet ('select N''w こんにちは ''' ddsel ch), 1000

Mike Chris

unread,
May 20, 2025, 8:20:08 AM5/20/25
to forum, chris burke

|value error: toutf8

Mike Chris

unread,
May 20, 2025, 8:24:34 AM5/20/25
to forum, chris burke

toutf8 each ddfet ('select N''w こんにちは ''' ddsel ch), 1000

|index error in toutf8, executing dyad u:

| 8 u:y

Press ENTER to inspect


On Tuesday, 20 May 2025 at 15:14:24 UTC+3 chris burke wrote:

bill lam

unread,
May 20, 2025, 8:59:01 AM5/20/25
to fo...@jsoftware.com
I should be utf8

BTW J script is already utf8 encoded. and J doesn't understand
National string format.
try instead
ddfet ('select ''こんにちは'''ddsel ch), 1000
> To unsubscribe from this group and stop receiving emails from it, send an email to forum+un...@jsoftware.com.
Message has been deleted

Mike Chris

unread,
May 20, 2025, 9:07:33 AM5/20/25
to forum, bill lam
Hi,
try instead
ddfet ('select N''こんにちは'''ddsel ch), 1000

That is what I tried from the beginning.
Outputs ????
Maybe J cannot handle this.

Thanks, Michael

bill lam

unread,
May 20, 2025, 9:14:33 AM5/20/25
to Mike Chris, forum
I suggested
ddfet ('select ''こんにちは'''ddsel ch), 1000
NOT
ddfet ('select N''こんにちは'''ddsel ch), 1000

why there is a w in the output?

Mike Chris

unread,
May 20, 2025, 9:27:40 AM5/20/25
to forum

Hi,
The N is needed before the single quote, to inform SQL Server that the
following is unicode string.
Select N'こ'
not
Select 'こ'

I have tried

ddfet ('select  ''こんにちは'''ddsel ch), 1000
returns ????

Thanks, Michael

bill lam

unread,
May 20, 2025, 9:40:12 AM5/20/25
to fo...@jsoftware.com
The N is not needed in J. If there are characters above 127, the whole sentence will be converted to utf16 before sending to SQL server.  I don't have access to SQL Server to test for the time being.

Mike Chris

unread,
May 20, 2025, 9:43:23 AM5/20/25
to forum, bill lam
from within MS SQL Server
select WithN=N'こんにちは'
こんにちは
select WithoutN='こんにちは'
?????
Reply all
Reply to author
Forward
0 new messages