ActiveState Perl 5.6. and Language Localization 
Author Message
 ActiveState Perl 5.6. and Language Localization

G'day,

Perl: ActiveState, 5.6.
Env.: Windows 2000, Service Pack 3.0.

I am trying to port this piece of code to Windows

use POSIX;
use locale;
setlocale(LC_CTYPE, "de_DE.ISO-8859-1"); (or any language)

What I am trying to do is using the native German/French characters as
alphanumeric, for example, in regular expression, or to get them
printed correctly with a print command, without conversion.

This mechanism is described in
http://www.*-*-*.com/

Unfortunately, altough this work fine in UNIX, this does not work for
Windows.
Can anyone help me?

Thank you very much.

/Pascal Lagass

K?sel GmbH & Co. KG - ber 400 Jahre Bcher mit System
Wartenseestra?e 11 87435 Kempten



Fri, 13 May 2005 16:58:53 GMT  
 ActiveState Perl 5.6. and Language Localization

Quote:

> G'day,

> Perl: ActiveState, 5.6.
> Env.: Windows 2000, Service Pack 3.0.

> I am trying to port this piece of code to Windows

> use POSIX;
> use locale;
> setlocale(LC_CTYPE, "de_DE.ISO-8859-1"); (or any language)

> What I am trying to do is using the native German/French characters as
> alphanumeric, for example, in regular expression, or to get them
> printed correctly with a print command, without conversion.

Use the encoding pragma.

   use encoding 'ISO-8859-1';

--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]



Mon, 16 May 2005 09:46:10 GMT  
 ActiveState Perl 5.6. and Language Localization
Thank you Benjamin,

Perl 5.6.1.
Env. Windows 2000, Service Pack 3.0.

Unfortunately, I did not found a reference to the encoding pragma in
ActiveState Dokumentation (perl 5.6) (although the utf8 pragma is
documented).
I did not found any reference to the pragma encoding in perlport
either.

I was unlunky with  "Programmieren mit Perl" (3rd Edition) von LW, TC
and JO.

But I do found reference to Encode in Perl 5.8. documentation.

And in CPAN, I found Encode.pm (from Dan Kogai) with the following
warning:

"This module requires perl version 5.7.3 or later."

Ho Ho, I guess that I must upgrade from 5.6. to 5.8.  One of the
problems that I got from migrating, is that the PPM format has changed
from 5.8. to 5.6., so there is a lot of CPAN modules that are not
available with PPM (it is a bit complicated when a CPAN module uses
other CPAN dependencies).

Anyway, I'll manage it, thank you for your help, it is greatly
appreciated!

/Pascal Lagass

K?sel GmbH & Co. KG - ber 400 Jahre Bcher mit System
Wartenseestra?e 11 87435 Kempten

Quote:


> > G'day,

> > Perl: ActiveState, 5.6.
> > Env.: Windows 2000, Service Pack 3.0.

> > I am trying to port this piece of code to Windows

> > use POSIX;
> > use locale;
> > setlocale(LC_CTYPE, "de_DE.ISO-8859-1"); (or any language)

> > What I am trying to do is using the native German/French characters as
> > alphanumeric, for example, in regular expression, or to get them
> > printed correctly with a print command, without conversion.

> Use the encoding pragma.

>    use encoding 'ISO-8859-1';



Tue, 17 May 2005 16:31:39 GMT  
 ActiveState Perl 5.6. and Language Localization

Quote:

> Thank you Benjamin,

> Perl 5.6.1.
> Env. Windows 2000, Service Pack 3.0.

> Unfortunately, I did not found a reference to the encoding pragma in
> ActiveState Dokumentation (perl 5.6) (although the utf8 pragma is
> documented).

That's because it doesn't come with ActiveState -- you have to install
it.  It's part of the Encode-1.83 distribution.

[snip]

Quote:
> But I do found reference to Encode in Perl 5.8. documentation.

> And in CPAN, I found Encode.pm (from Dan Kogai) with the following
> warning:

> "This module requires perl version 5.7.3 or later."

For most of the features, it does, but some things should be able to
work with 5.6.1.

Quote:
> Ho Ho, I guess that I must upgrade from 5.6. to 5.8.  One of the
> problems that I got from migrating, is that the PPM format has changed
> from 5.8. to 5.6., so there is a lot of CPAN modules that are not
> available with PPM (it is a bit complicated when a CPAN module uses
> other CPAN dependencies).

If you really want to avoid upgrading, and avoid installing Encode, you
could install Filter::Util::Call, and Text::Iconv, and write your own
source filter which changes the encoding.

--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]



Fri, 20 May 2005 05:54:08 GMT  
 ActiveState Perl 5.6. and Language Localization
Thanks Benjamin,

Now with Encoding I can use the in Regular Expression as \w.

What I do not exactly understand is the behavior of  "print":
#---------------------------
use strict;
use encoding '"de_DE.ISO-8859-1';
print "\n";
#-----------------------
I got:
▄ (Well an interesting character that I can't print in a newsgroup).

What did I missed? (If I may ask another question?).

Thank you 1000 times.

/Pascal

Quote:


> > Thank you Benjamin,

> > Perl 5.6.1.
> > Env. Windows 2000, Service Pack 3.0.

> > Unfortunately, I did not found a reference to the encoding pragma in
> > ActiveState Dokumentation (perl 5.6) (although the utf8 pragma is
> > documented).

> That's because it doesn't come with ActiveState -- you have to install
> it.  It's part of the Encode-1.83 distribution.

> [snip]
> > But I do found reference to Encode in Perl 5.8. documentation.

> > And in CPAN, I found Encode.pm (from Dan Kogai) with the following
> > warning:

> > "This module requires perl version 5.7.3 or later."

> For most of the features, it does, but some things should be able to
> work with 5.6.1.

> > Ho Ho, I guess that I must upgrade from 5.6. to 5.8.  One of the
> > problems that I got from migrating, is that the PPM format has changed
> > from 5.8. to 5.6., so there is a lot of CPAN modules that are not
> > available with PPM (it is a bit complicated when a CPAN module uses
> > other CPAN dependencies).

> If you really want to avoid upgrading, and avoid installing Encode, you
> could install Filter::Util::Call, and Text::Iconv, and write your own
> source filter which changes the encoding.



Sat, 21 May 2005 16:23:12 GMT  
 ActiveState Perl 5.6. and Language Localization

Quote:

> Thanks Benjamin,

> Now with Encoding I can use the in Regular Expression as \w.

Ahh, no, I don't think so.  To get \w in a regexp to match , you need
to have the 'use locale' pragma in scope.

Quote:
> What I do not exactly understand is the behavior of  "print":
> #---------------------------
> use strict;
> use encoding '"de_DE.ISO-8859-1';

This line should be:

   use encoding 'ISO-8859-1';

The de_DE that you see in your locale has to do with LC_CTYPE and
LC_COLLATE, and little or nothing to do with the encoding.

Quote:
> print "\n";
> #-----------------------
> I got:
> ▄ (Well an interesting character that I can't print in a
> newsgroup).

> What did I missed? (If I may ask another question?).

You missed that when you print, your data is converted from characters
into bytes, and that 'use encoding' also specifies *how* to convert from
characters into bytes ... your terminal interpreted those bytes
differently from what you expected.

   use encoding 'ISO-8859-1', STDOUT => $terminal_encoding;

Where $terminal_encoding is whatever your terminal expects... I have no
idea what this is on your system, so cannot help you.

--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]



Mon, 23 May 2005 05:21:20 GMT  
 ActiveState Perl 5.6. and Language Localization
G'day Benjamin,

After your last post, I got the EUREKA!

This program works with ActiveState Perl 5.8., Windows 2000, with
Terminal printing and Regular Expression.

# ----------------------------------------------------------
use strict;
# use locale; does not seem to do a difference in DOS mit AP 5.8.

use encoding 'ISO-8859-1', STDOUT => 'cp850';

  # test the printing at the Terminal
print "TF\n";

  # Test the regular expression
my $data = "";
print "Success" if $data =~ /\w/;

What I got is:
# ----------------------------------
C:\>perl -w -S encoding.pl
TF
Success
# ----------------------------------

For this example, I did not use the "use locale;" pragma, since I use
ActivePerl in DOS.  Nevertheless, it works.
I guess that the POSIX locale are not used in this environment.

Thanks, I think that you should write an Article in this thema, I do
not think that I am the only one that got this problem.

Best regards,

/Pascal Lagass

K?sel GmbH & Co. KG - ber 400 Jahre Bcher mit System
Wartenseestra?e 11 87435 Kempten



Mon, 23 May 2005 16:46:16 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. SQL STATEMENT

2. problem with the BDE

3. Use TP7's PutPixel to show BMP is very slowly!

4. TO Steve Koterski Borland

5. Tech support on the net????

6. Is there a way to have the data and time posted at the

7. ActiveState Perl 5.6 - Can't exit WHILE loop

8. Install MailTools on ActiveState perl 5.6 !!!

9. NEWBIE: Using Win32::Eventlog under Activestate Perl 5.6 (Win XP)

10. Perl 5.6 Activestate crashes in Windows 98

11. NEWBIE: Using Win32::Eventlog under Activestate Perl 5.6 (Win XP)

 

 
Powered by phpBB® Forum Software