CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner:
Reg. Chinese chars ???

 



dr.codin
New User

Sep 8, 2012, 4:41 AM

Post #1 of 3 (1193 views)
Reg. Chinese chars ??? Can't Post

Hi Experts,

I'm trying to pull some Chinese text from my DB tables and generating an XLS. But the text is getting converted to '?' symbols.

Seems like some Encoding problem.
I tried Encode::encode('UTF-8',<text>) but dint work... :(

Help is really appreciated. TIA.

Thanks & Regards,
dr.codin


Zhris
Enthusiast

Sep 8, 2012, 5:06 PM

Post #2 of 3 (1183 views)
Re: [dr.codin] Reg. Chinese chars ??? [In reply to] Can't Post

Hey,

Have you taken a look at Encode::CN (http://search.cpan.org/~dankogai/Encode-2.47/CN/CN.pm)


Code
$utf8_string = decode("euc-cn", $chinese_string);


Chris


dr.codin
New User

Sep 12, 2012, 9:17 PM

Post #3 of 3 (1094 views)
Re: [Zhris] Reg. Chinese chars ??? [In reply to] Can't Post

Thanks Zhris.
But i cant make the script so specific to only CN...

i need to make it generic UTF-8 to handle all languages.

Below is the code which writes the text into XLS file -


Code
sub write_file                  
{
my $contents = shift;
my $filename = shift;
$g_error_message .= "Writing empty file $filename" unless $contents =~ /\S/;

open(FILE1,"> $filename");
#print_log('filenamessS--- '.$filename);
#open(FILE1,">:encoding(UTF-8)","$filename");
#print_log('contentssS--- '.Encode::encode( "UTF-8", $contents ));
#my $contents_utf = Encode::encode( "UTF-8", $contents );
#open (FILE1 ,"> encoding(utf8)", "$filename");
binmode FILE1,':utf8';
print FILE1 $contents;
close FILE1;
return 0;
}


Any pointers to this experts ???
Help really appreciated...

Thanks & Regards,
dr.codin


(This post was edited by dr.codin on Sep 12, 2012, 9:19 PM)

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives