[dancer-users] character encoding

WK wanradt at gmail.com
Wed Dec 18 21:00:28 GMT 2013

2013/12/18 Attila Bárdi <attila.bardi at gmail.com>

> I have an openldap server and I do some search in there.
> So when I search for for example to my displayName, the ldap modul found
> the following:
> battila at igornb:~$  ./test_ldap.pl
> LdapPerson module is successfully loaded!
> displayname: Bárdi Attila
> battila at igornb:~$
> test.pl:
> *#!/usr/bin/perl -wuse strict;use warnings;use LdapPerson;*

Don't you get any "wide character" warnings?

As far as I understand you have problem with decoding your input from LDAP.

When you use your module without Dancer you seem not decode your input and
Perl treats your input by bytes and on print it outputs these same bytes.
So, when you have UTF-8 enabled environment those bytes are shown as right
characters even when they are not meant as such.

Now, using Dancer you tell explicitly to use UTF-8 and because your input
is not decoded properly (not marked as UTF-8) Dancer will treat this string
as Latin1 and decodes bytes after ASCII-set again to its inner Unicode and
on printing again to UTF-8. This causes such output as you have.

You could add to your test.pl one line to test your output filters:

print join( ' ', PerlIO::get_layers('STDOUT') ), "\n";

If the last filter is not "utf8", my conclusion should be right.

Kõike hääd,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20131218/0533de53/attachment.html>

More information about the dancer-users mailing list