Skip to content

malformed utf-8 error [rt.cpan.org #118004] (Locale::Maketext) #18502

Open
@toddr

Description

@toddr

Migrated from rt.cpan.org#118004

Requestors:
@binary-com

Attachments:

From @binary-com on 2016-09-21 03:26:57
I found one issue with Locale::Maketext module as explained below

Consider this as translated string

msgid "Opens late (at %1)"
msgstr "�ffnet spät (um %1)"

So when I try to do maketext on this, i get this error

Malformed UTF-8 character (unexpected end of string) in string ne at /usr/share/perl/5.14/Locale/Maketext.pm line 541.

As a fix i changed this line https://metacpan.org/source/TODDR/Locale-Maketext-1.28/lib/Locale/Maketext.pm#L736

to

elsif(do {my $x = $1; substr($x,0,1)} ne '~') {

or to this

elsif(substr("$1",0,1) ne '~') {

then it works fine.

Additional information:

Perl Version: 5.14.2
Module Version: 1.28

I have attached the output.log as trace if you need it, attached below is snippet of it

SV = PVMG(0x1ead340) at 0x1ed8600
  REFCNT = 1
  FLAGS = (GMG,SMG,pPOK,UTF8)
  IV = 0
  NV = 0
  PV = 0x58edf40 "\303\226ffnet sp\303\244t (um "\0 [UTF8 "\x{d6}ffnet sp\x{e4}t (um "]
  CUR = 18
  LEN = 952
  MAGIC = 0x39cb390
    MG_VIRTUAL = &PL_vtbl_utf8
    MG_TYPE = PERL_MAGIC_utf8(w)
    MG_LEN = -1
    MG_PTR = 0x39c46f0
       0: 1 -> 1
       1: 0 -> 0
  MAGIC = 0x1edf8b0
    MG_VIRTUAL = &PL_vtbl_sv
    MG_TYPE = PERL_MAGIC_sv(\0)
    MG_OBJ = 0x1ed85e8
    MG_LEN = 1
    MG_PTR = 0x1edf4e0 "1"
SV = PV(0x575c630) at 0x20710c8
  REFCNT = 1
  FLAGS = (PADMY,POK,pPOK,UTF8)
  PV = 0x3aac1e0 "\303"\0SV = PVMG(0x1ead340) at 0x1ed8600
  REFCNT = 1
  FLAGS = (GMG,SMG,pPOK,UTF8)

The first dump is $1. That one is correct. It's a UTF8 string (\303\244...) and the UTF8 flag is set.

The 2nd one is the substr result.

It's value is only \303, one byte. But the UTF8 flag is set.

Metadata

Metadata

Assignees

No one assigned

    Labels

    dist-Locale-Maketextissues in the blead-first Locale-MakeText distribution

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions