LibreCat / Catmandu-Store-MongoDB

A searchable store backed by MongoDB
https://metacpan.org/pod/Catmandu::Store::MongoDB
4 stars 2 forks source link

Retrieving strings with umlauts fails #4

Closed vpeil closed 10 years ago

vpeil commented 10 years ago

I've added a test in my fork: https://github.com/vpeil/Catmandu-Store-MongoDB/blob/pr/test/t/01-store.t

What's wrong with this? Maybe, there's the same problem with other characters?

phochste commented 10 years ago

Mixing utf8 code into Perl is always problematic. Shouldn’t you use:

use utf8;

When putting non-ascii characters in a Perl script?

From: Vitali Peil notifications@github.com<mailto:notifications@github.com> Reply-To: LibreCat/Catmandu-Store-MongoDB reply@reply.github.com<mailto:reply@reply.github.com> Date: Tuesday 26 August 2014 13:49 To: LibreCat/Catmandu-Store-MongoDB Catmandu-Store-MongoDB@noreply.github.com<mailto:Catmandu-Store-MongoDB@noreply.github.com> Subject: [Catmandu-Store-MongoDB] Retrieving strings with umlauts fails (#4)

I've added a test in my fork: https://github.com/vpeil/Catmandu-Store-MongoDB/blob/pr/test/t/01-store.t

What's wrong with this? Maybe, there's the same problem with other characters?

— Reply to this email directly or view it on GitHubhttps://github.com/LibreCat/Catmandu-Store-MongoDB/issues/4.

vpeil commented 10 years ago

Thanks, this works, but now you get warnings (stripped unsupported regex flag /u from MongoDB regex)! The reason:

#!/usr/bin/env perl
use utf8;

my $regex = qr/möller/i;

print $regex; # you see the i-flag and the u-flag, because of utf-8 encoding

But the original MongoDB client does not support the /u-flag and throws a warning (see here: https://github.com/mongodb/mongo-perl-driver/blob/4a66960b5970fe153d29514e35385b5c8fc2af0e/perl_mongo.c#L1545)

You can enable/disable flags for regexes, but no re '/u'; has no effect in combination with use utf8;

Conclusion: It's not a problem of this module and I have to live with the warning :cry: