Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re:^2 DBM modules and unicode keys

by ph0enix (Friar)
on Nov 22, 2002 at 15:03 UTC ( [id://215112]=note: print w/replies, xml ) Need Help??


in reply to Re: DBM modules and unicode keys
in thread DBM modules and unicode keys

I tried following code without success. Looks like return only octets instead of string...

(tied %data)->filter_fetch_key( sub { decode('utf8', $_); } ); print join(', ', keys %data), "\n";

But this code produces correct output

print join(', ', map { decode('utf8', $_) } keys %data), "\n";

Another hint?

Replies are listed 'Best First'.
Re: Re:^2 DBM modules and unicode keys
by demerphq (Chancellor) on Nov 22, 2002 at 15:54 UTC
    Well i would guess that you need to encode the data as you put it in the DB and then decode it when you take it out. The code you have posted suggests that you are trying to extract from a DB created without using an appropriate filter_store_key(). I would delete the db, construct the appropriate store and fetch filters and then try rebuilding it.

    Im sorry I cant help more than that, im not too familiar with the ins and outs of UTF8, but this is definately where I would start to try to solve the problem.

    --- demerphq
    my friends call me, usually because I'm late....

      By reading docs again and again I found my mistake. The $_ variable must be modified instead of returning value, because the return code from the filter is ignored. Thank you

      The correct filtering function is

      (tied %data)->filter_fetch_key( sub { $_ = decode('utf8', $_); } );

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://215112]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-16 04:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found