Skip to content

Reading/writing PO files #95

@mlocati

Description

@mlocati

I created a PHP file like this:

<p><?php __("Char x00: \x00"); ?></p>
<p><?php __("Char x01: \x01"); ?></p>
// omissis
<p><?php __("Char xfe: \xfe"); ?></p>
<p><?php __("Char xff: \xff"); ?></p>

And I run xgettext --from-code=utf-8 --language=PHP --keyword=__.

For the chars \x80 through 0xff it showed the following error:
invalid multibyte sequence
and the chars where passed as-is in the PO file

Only the following conversions occurred:

msgid "Char x00: " <- stripped out
msgid "Char x07: \a"
msgid "Char x08: \b"
msgid "Char x09: \t"
msgid "Char x0a: \n"
msgid "Char x0b: \v"
msgid "Char x0c: \f"
msgid "Char x0d: \r"
msgid "Char x22: \""
msgid "Char x5c: \\"

But for \x07 (\a), \x08 (\b), \x0b (\v), \x0c (\f), \x0d (\r), xgettext printed out error messages like this:

warning: internationalized messages should not contain the '\...' escape sequence

So, I think that when converting strings to PO we should:

  • strip out \x00
  • convert only \t, \n, " and \

But when converting strings from PO we should convert all the recognized sequences, I mean

  • \a => "\x07"
  • \b => "\x08"
  • \t => "\x09"
  • \n => "\x0a"
  • \v => "\x0b"
  • \f => "\x0c"
  • \r => "\x0d"
  • \" => "\x22"
  • \\ => "\x5c"

If it's ok, I'll update the pull request #93

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions