Subject: | Cannot generate classes with widechar in table comment |
Hello,
Last Version of Schema::Loader hat implemeneted new feature:
POD-Documentation contains table comments. But if this comment contains
wide characters (i.e. german umlauts üöä) generation of classes breaks
with a message:
Wide character in subroutine entry at DBIx/Class/Schema/Loader/Base.pm
line 1444
The problem is that this call Digest::MD5::md5_base64($compare_to) is
not UTF8-concerned. Documentation for Digest::MD5 answers for it:
----
What you can do is calculate the MD5 checksum of the UTF-8
representation of such strings. This is achieved by filtering the string
through encode_utf8() function:
use Digest::MD5 qw(md5_hex);
use Encode qw(encode_utf8);
my $str = "abc\x{300}";
print md5_hex(encode_utf8($str)), "\n";
# 8c2d46911f3f5a326455f0ed7a8ed3b3
----
To reproduce this error it shuold be created the table with a comment
(Für Test) - with umlaut or other wide character
The solution is (in DBIx::Class::Schema::Loader::Base):
1. use Encode qw(encode_utf8);
2. Call for Digest::MD5::md5_base64 always should be with encode_utf8:
p. 1444: if (Digest::MD5::md5_base64(encode_utf8($compare_to)) eq
$old_md5) {
p. 1458: print $fh $text .
Digest::MD5::md5_base64(encode_utf8($text)) . "\n";
Info:
Schema::Loader: 0.07010
Digest::MD5: 2.51
Perl: 5.10.0
OS: Linux NCvBillE01e 2.6.16.46-0.12-smp #1 SMP Thu May 17 14:00:09 UTC
2007 x86_64 x86_64 x86_64 GNU/Linux
Thank you,
Alex