Re: Unicode, Null Code or Something Else

2013-01-24 Thread Glenn Linderman

On 1/24/2013 9:36 AM, Paul Rousseau wrote:

Hello Perl forum.

I am attempting to parse a file that contains a format I am not 
familiar with. I read in a record and assign it to $string.


$string = N o r m a n d v i l l e A d m i n

When I dump the string using this code,

while ($string =~ /./g)
  {
   print $ and  . ord($) .  length  . length($);
  }

I get

  and 0 length 1
N and 78 length 1
  and 0 length 1
o and 111 length 1
  and 0 length 1
r and 114 length 1
  and 0 length 1
m and 109 length 1
  and 0 length 1
a and 97 length 1
  and 0 length 1
n and 110 length 1
  and 0 length 1
d and 100 length 1
  and 0 length 1
v and 118 length 1
  and 0 length 1
i and 105 length 1
  and 0 length 1
l and 108 length 1
  and 0 length 1
l and 108 length 1
  and 0 length 1
e and 101 length 1
  and 0 length 1
A and 65 length 1
  and 0 length 1
d and 100 length 1
  and 0 length 1
m and 109 length 1
  and 0 length 1
i and 105 length 1
  and 0 length 1
n and 110 length 1
  and 0 length 1

Can someone answer two questions for me please?

1. What format does this represent?
2. What function or library or regexp can I use to convert the string 
to the basic ASCII so that all these null codes go away? (In other 
words, I want to convert $string to NormandvilleAdmin)


You should read about UTF-16BE encoding.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: Unicode, Null Code or Something Else

2013-01-24 Thread Paul Rousseau

Thank you Glenn.
 
open(my $file,:encoding(UTF-16), $filename) 
 
This works.
 
Paul

 




Date: Thu, 24 Jan 2013 09:39:49 -0800
From: v+p...@g.nevcal.com
To: perl-win32-users@listserv.ActiveState.com
Subject: Re: Unicode, Null Code or Something Else


On 1/24/2013 9:36 AM, Paul Rousseau wrote:




Hello Perl forum.
 
I am attempting to parse a file that contains a format I am not familiar with. 
I read in a record and assign it to $string.
 
$string = N o r m a n d v i l l e A d m i n
 
When I dump the string using this code,
 
while ($string =~ /./g)
  {
   print $ and  . ord($) .  length  . length($);
  }

I get
 
  and 0 length 1
N and 78 length 1
  and 0 length 1
o and 111 length 1
  and 0 length 1
r and 114 length 1
  and 0 length 1
m and 109 length 1
  and 0 length 1
a and 97 length 1
  and 0 length 1
n and 110 length 1
  and 0 length 1
d and 100 length 1
  and 0 length 1
v and 118 length 1
  and 0 length 1
i and 105 length 1
  and 0 length 1
l and 108 length 1
  and 0 length 1
l and 108 length 1
  and 0 length 1
e and 101 length 1
  and 0 length 1
A and 65 length 1
  and 0 length 1
d and 100 length 1
  and 0 length 1
m and 109 length 1
  and 0 length 1
i and 105 length 1
  and 0 length 1
n and 110 length 1
  and 0 length 1
 
Can someone answer two questions for me please?
 
1. What format does this represent?
2. What function or library or regexp can I use to convert the string to the 
basic ASCII so that all these null codes go away? (In other words, I want to 
convert $string to NormandvilleAdmin)

You should read about UTF-16BE encoding.

___ Perl-Win32-Users mailing list 
Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: 
http://listserv.ActiveState.com/mailman/mysubs  
  ___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs