Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
toddr opened this issue Jan 22, 2021 · 1 comment
Open

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

toddr opened this issue Jan 22, 2021 · 1 comment
Labels
dist-Locale-Maketext issues in the blead-first Locale-MakeText distribution

Comments

@toddr
Copy link
Member

toddr commented Jan 22, 2021

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.

@toddr toddr changed the title malformed utf-8 error [rt.cpan.org #118004] malformed utf-8 error [rt.cpan.org #118004] (Locale::Maketext) Jan 22, 2021
@Leont
Copy link
Contributor

Leont commented Jan 23, 2021

That fix shouldn't fix anything, something weird is going on here.

@karenetheridge karenetheridge added dist-Locale-Maketext issues in the blead-first Locale-MakeText distribution and removed Needs Triage labels Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dist-Locale-Maketext issues in the blead-first Locale-MakeText distribution
Projects
None yet
Development

No branches or pull requests

3 participants