By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,851 Members | 1,410 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,851 IT Pros & Developers. It's quick & easy.

Unicode help

P: 1
Before I begin to explain my problem, I just want to say that I can do the following two things:

1. Using Perl, connect to a MS Access Databse Table and perform the required operations.(Database is in English language)
2. I can read and write UTF8 text files using Perl.

The following code explains how do I write UTF8 files.:

Expand|Select|Wrap|Line Numbers
  1. $infile="out2.txt";
  2. #$outfile="out.txt";
  3. #open (FH,">:utf8",$outfile);
  4.  
  5. open(F,"<:utf8",$infile);
  6.  
  7. while(<F>){
  8. chomp;
  9.  
  10. binmode(STDOUT,":utf8");
  11.  
  12. print "$_"."\n";
  13.  
  14. }
  15. if($_ == /\x{0932}/)
  16. {
  17.  
  18. print "L"; 
  19. }
  20. $strvar="\x{0932} \x{0917}";
  21. print $strvar."done"."\n";
  22. #print FH $strvar."\n";
  23. close(F);
Here, I am reading from one UTF8 file and writing to another UTF8 file. Also, in the new UTF8 file I am adding two more characters whose hex values are there in the variable "strvar" as can be seen in the program. Now when I see this file in Wordpard or Notepad everything is fine.

Now I come to my question.
I have enabled Hindi Language/Internationalization support on my machine. If I directly try to write Hindi to the tables in MS Access, I am able to do that. Now the problem is that when I try to insert a string into MS Access from Perl whose Hex value(Unicode) is \x{0932} it does not appear correctly in the table. The Character that should appear corresponding to 0932 Hex is shown below(You can see this if you have Unicode support on your machine).


However, instead of the above character, some garbled character is displayed on the screen. I dnt know how to insert unicode characters into MS Access from Perl(That is issuing a insert query from Perl to insert unicode strings). I need urgent help on this. I would really appreciate if someone could help me out.

thanks in advance.

Kanwaljeet
Jan 12 '08 #1
Share this Question
Share on Google+
2 Replies


eWish
Expert 100+
P: 971
Welcome to TSDN!

When you insert the data are you using placeholders? Are you expecting to see the hexadecimal representation in the db or the actual character after the insert?

--Kevin
Jan 13 '08 #2

P: 2
Can I hijack this thread? I'm having exactly the same problem.

Yes, I'm using placeholders to insert data in MSAccess. From in MSAccess I see the UTF8 characters as two separate characters.

When I'm doing a select from Perl, I do get the characters in UTF8 format back (when printing to a file).

So it seems perl treats characters as 8 bit objects, splitting up UTF8 characters in 2 (or more) pieces. Because in MSAccess each 8bit part of the UTF8 character is visible as a separate character

I'm using activestate Perl 5.10 with DBD::ADO

Bart
Jan 30 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.