Skip to content
This repository has been archived by the owner on May 23, 2019. It is now read-only.

Using escaped \ causes syntax error #109

Closed
jithine opened this issue Aug 10, 2015 · 2 comments
Closed

Using escaped \ causes syntax error #109

jithine opened this issue Aug 10, 2015 · 2 comments

Comments

@jithine
Copy link

jithine commented Aug 10, 2015

I am unable to use this string ' i am \ back slash' on a message. Getting this error

SyntaxError{message: 'Expected "\\#", "\\u", "\\{", "\\}", "{", [^{}\\\0-\x1F \t\n\r], end of input or whitespace but "\\" found.', expected: [Object{type: ..., value: ..., description: ...}, Object{type: ..., value: ..., description: ...}, Object{type: ..., value: ..., description: ...}, Object{type: ..., value: ..., description: ...}, Object{type: ..., value: ..., description: ...}, Object{type: ..., value: ..., description: ...}, Object{type: ..., description: ...}, Object{type: ..., description: ...}], found: '\', offset: 77, line: 1, column: 78, name: 'SyntaxError'}

My use case is to render a message which has back slash in it. How can I do this ?

@ericf ericf added the bug label Aug 21, 2015
@ericf
Copy link
Collaborator

ericf commented Aug 21, 2015

This seems like a bug in intl-messageformat-parser.

@ericf
Copy link
Collaborator

ericf commented Aug 21, 2015

I'll add a change to intl-messageformat-parser which supports the literal backslash char (\) so that it would look something like:

var msg = new IntlMessageFormat('I am a \\\\ backslash');

For the time being, you can use the unicode code point \u005c like this:

var msg = new IntlMessageFormat('I am a \\u005c backslash');

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants