MACSCRPT Archives

January 2006

MACSCRPT@LISTSERV.DARTMOUTH.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
John Delacour <[log in to unmask]>
Reply To:
Macintosh Scripting Systems <[log in to unmask]>
Date:
Fri, 27 Jan 2006 17:53:29 +0000
Content-Type:
text/plain
Parts/Attachments:
text/plain (74 lines)
[ Very curious behaviour of the list server and Mail.app -- I got the  
copy fine but the list message was missing a whole chunk.  Here's  
another try ]



I'm having a problem getting Unicode into MySQL using Perl and the  
DBI Module and wonder if anyone here can suggest what might be wrong.

MYSQL is set up with character set utf8 throughout as shown after my  
signature.

With AppleScript I have no problem getting the result I want with the  
following script:


         set _name to quoted form of (do shell script "perl -e '
         print qq~\\x{90ed}\\x{6c5f}~'")
         set _town to quoted form of (do shell script "perl -e '
         print qq~\\x{6c55}\\x{982d}~'")
         tell application "Terminal" to do script "mysql
         use test;
         drop table if exists china;
         create table china (
           id integer,
           name text,
           town text
         );
         insert into china values
         (1," & _name & ", " & _town & ");
         select * from china;
         exit;" in window 1

+------+--------------+---------------+
| id   | name         | town          |
+------+--------------+---------------+
|    1 |  郭江         |  汕頭         |
+------+--------------+---------------+

But no matter what I do, if I try the same thing with Perl and DBI, I  
get the following result, that is the Latin-1 equivalent of the raw  
utf-8 bytes.


+------+--------------+---------------+
| id   | name         | town          |
+------+--------------+---------------+
|    1 | éƒ江       | 汕é         |
+------+--------------+---------------+



JD

mysql  Ver 14.12 Distrib 5.1.5-alpha, for apple-darwin8.4.0 (powerpc)  
using  EditLine wrapper

Connection id:          37
Current database:       test
Current user:           jd@localhost
SSL:                    Not in use
Current pager:          stdout
Using outfile:          ''
Using delimiter:        ;
Server version:         5.1.5-alpha-log
Protocol version:       10
Connection:             Localhost via UNIX socket
Server characterset:    utf8
Db     characterset:    utf8
Client characterset:    utf8
Conn.  characterset:    utf8
UNIX socket:            /tmp/mysql.sock
Uptime:                 49 min 22 sec

ATOM RSS1 RSS2