Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Character encoding woes - unicode or not?

by repellent (Priest)
on Feb 01, 2012 at 07:04 UTC ( #951131=note: print w/replies, xml ) Need Help??


in reply to Character encoding woes - unicode or not?

use Encode qw(decode); sub decode_it { my $s = shift; eval { $s = decode('UTF-8', $s, 1); 1; } or do { $s = decode('latin1', $s, 1); }; return $s; } use Devel::Peek qw(Dump); Dump decode_it($_) for "\xE2\x84\xA2", "\xE7\xE1"; __END__ SV = PV(0x100820708) at 0x10081c248 REFCNT = 1 FLAGS = (TEMP,POK,pPOK,UTF8) PV = 0x100202140 "\342\204\242"\0 [UTF8 "\x{2122}"] CUR = 3 LEN = 8 SV = PV(0x100820748) at 0x100860ee0 REFCNT = 1 FLAGS = (TEMP,POK,pPOK,UTF8) PV = 0x10025dec0 "\303\247\303\241"\0 [UTF8 "\x{e7}\x{e1}"] CUR = 4 LEN = 8

Once decoded by decode_it, your character strings are ready to be UTF-8 encoded right before you put it out onto your web page.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://951131]
help
Chatterbox?
[shmem]: well finally.
[stevieb]: nice! I just finished a GPS "take me home" device last week, and did a bunch of software updates to it yesterday. I also created a pseudo chip with an Arduino to simulate an IC, where it responds to register read/writes over the I2C bus...
[stevieb]: ...from an I2C master. It's ugly and there are many changes I'm going to make, but I had not done anything like it before. It's designed for my RPi:: automated test platform; a system that does CI on *all* my RPi modules.
[shmem]: pseudo chip?

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2017-06-25 22:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (572 votes). Check out past polls.