Current location: Hot Scripts Forums » Programming Languages » Perl » getting perl to create files with russian names


getting perl to create files with russian names

Reply
  #1 (permalink)  
Old 11-25-08, 11:22 AM
squashed squashed is offline
New Member
 
Join Date: Nov 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
getting perl to create files with russian names

Hi all,

I'm trying to create files on a Windows XP machine that hold russian language content. The content is generated with perl scripts. The problem is that when I try to give the files meaningful russian names, the filenames come out garbled.

For example:

$u = "работать" ;

$f = magic($u) ; # the magic function is what I am looking for...

open O,">$f" ;

the kind of magic I am trying results in filenames like работать.html
I've tried using encode/decode functions, but I'm obviously not doing it right.


thanks for reading
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-05-09, 05:58 AM
phranque phranque is offline
New Member
 
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
did you "use Encode;"?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-05-09, 03:23 PM
drowzee drowzee is offline
Newbie Coder
 
Join Date: Dec 2008
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
phranque is right.

use Encode like this:
-----------------------------------
use utf8;
use Encode;

$u = "работать";

$f = encode("cp1251", $u);

open O, ">$f" or die "OMG!";

close O;
-----------------------------------

or just save your source .pl file as ANSI text, it will create file without any additional charset conversions.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 03-03-10, 07:57 PM
ukndoit ukndoit is offline
New Member
 
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
same problem...

I am having problems with it to.

I added this to the MySql database with phpMyAdmin:
Карту был заблокирован по следующей причине:

and it added it correctly, that is what I see in the database.
however when Perl gets it and prints it to the page, I see this:
????? ??? ???????????? ?? ????????? ???????:

for each cryllyc character, it replaces it with a ? and I even changed my page encoding to:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

that did not do it either.

I am lost as to why I can see it correctly in phpMyAdmin, but not in my Perl output pages.
If I use my language tag editor and change it with the form in my perl script, somehow it saves as encoded this way:
%26#1050;%26#1072;%26#1088;%26#1090;%26#1091; %26#1073;%26#1099;%26#1083; %26#1079;%26#1072;%26#1073;%26#1083;%26#1086;%26#1 082;%26#1080;%26#1088;%26#1086;%26#1074;%26#1072;% 26#1085; %26#1087;%26#1086; %26#1089;%26#1083;%26#1077;%26#1076;%26#1091;%26#1 102;%26#1097;%26#1077;%26#1081; %26#1087;%26#1088;%26#1080;%26#1095;%26#1080;%26#1 085;%26#1077;:
(I had to change the & to %26 or the broswer changed the encoding back to cryllyc)

Any ideas as to why Perl does not seem to like the characters in cryllyc?


BTW, here is how I try to display it on the page:
for debugging:
#perl script:
print "encoded: " . encode("cp1251", $_tr->{value});


Thank you,
Richard
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 03-03-10, 11:17 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
create files in php banli PHP 3 10-31-08 10:49 PM
how to read gzip files in perl perl.secret Perl 10 09-28-06 02:56 PM
Perl FormMail Problem ennanguyen2002 Perl 2 03-09-05 05:47 PM
Declared Functions skipper23 PHP 4 12-17-03 11:06 AM
index page not showing up skipper23 PHP 3 12-15-03 02:10 PM


All times are GMT -5. The time now is 09:13 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.