How to fix "ICU Syntax Error: Expected > "identifier" but found "0"." error in Flutter 3.7.0 - flutter

After Updating to Flutter 3.7.0 i get this error message when i build my App:
[app_en.arb:scanCode_fieldNotMatched] ICU Syntax Error: Expected
"identifier" but found "0".
field to match is "{0}"
It seems as if something had changed in how the variables are written in the .arb localization files.

UPDATE 1: Escape syntax characters!
If what you are trying is to use the characters {, }, ' (or any other syntax character for that matter) in your strings, then you will have to escape them. To do that enable the use-escaping flag by adding the following to l10n.yaml
use-escaping: true
Now use pairs of single quotes to escape syntax characters, like "{". To escape single quotes you just have to write it as a double-single quote as follows:
{
"some_text": "Using the '{' character '{isn''t}' trivial?"
}
More details on this in the flutter docu.
Update 2: If you are using a Chinese Mirror for Flutter
Follow details in this issue.
Original answer to my punctual problem
I found out that the reason for this error is that in Flutter 3.7
Internationalization support has been completely revamped! [they]’ve completely rewritten the gen-l10n tool...
as stated in a release post.
Previously i was declaring strings in my .arb file as follows
"scanCode_fieldNotMatched": "field to match is \"{0}\"",
where afterwards i was replacing {0} by some other value.
Well, it seems that now the gen-l10n tool takes what is between brackets as special parameters, and the name "0" is not accepted so i had to change my string to
"scanCode_fieldNotMatched": "field to match is \"{value0}\"",
and AppLocalizations can be now called as:
AppLocalizations.of(context)!.scanCode_fieldNotMatched("something here to replace value0!")
Further details on this can be found here: Placeholders, plurals, and selects in Flutter.

In my case, it was due to a translation string in my arb file for intl package. I had:
"{x, plural, =1{item}, other{items}}" (worked fine in previous versions)
This broke in Flutter 3.7. The solution for me was removing a comma:
"{x, plural, =1{item} other{items}}" (works in Flutter 3.7)

Related

How to fix ICU Lexing Error: Unexpected character in Flutter

I am using flutter_localizations to localize my app.
Since updating to Flutter 3.7 i am getting this error:
ICU Syntax Error: Expected "identifier" but found "}".
This =|(){}[] obviously
This =|\(){}[] obviously is the text that i have in my .arb file.
I understand that curly braces "{}" have a special meaning and should be escaped, but i can not find the way to correctly escape them, has anyone managed to do so?
One simple way to reproduce the issue is simply following the steps to add localization support here, and then instead of the hello world string, write anything that includes the character "{".
P.S.: There is a releted issue open on Github. Be sure to go and check there for updates!
There is an escaping syntax that is implemented but not enabled by default as it is a new feature that wasn't completely backward compatible with existing ICU message strings.
First, add the following to your l10n.yaml file:
use-escaping: true
Then, this will allow you to wrap parts of your strings in single quotes to ignore any syntax within the single quotes; to use a single quote normally as a character and not an escape, use a double single quote. For example,
{
message: "This '{isn''t}' obvious"
}
becomes
String get message => "This {isn't} obvious";
See here for information on the syntax. I'll add this to the documentation later.

Does angular dart have a built in function to remove illegal file-name characters from a string

In angular dart (using Visual Studio Code) If the user-clicks on a report such as "A/R Listing" to export to a CSV file. I need to remove the "/" from the name. I know I can just to a string replace for "/" but since the name of the report can be customized, it could be anything. Is there a function native to dart that knows which characters are illegal or does that all have to be done manually?
Thanks

utf8 inputenc error (RStudio & knitr & pdflatex); unknown unicode character 150=U+0096

I originally ran my .Rnw-file with the latex option:
\usepackage[utf8]{inputenc}
It produced an error:
"! Package inputenc Error: Unicode char \u8: not set up for use with LaTeX."
I switched to [utf8x], which generated a somewhat more helpful error message:
"! Package ucs Error: Unknown Unicode character 150 = U+0096,
(ucs) possibly declared in uni-0.def."
I tried to replace the 0096 (http://www.charbase.com/0096-unicode-start-of-guarded-area) character with \DeclareUnicodeCharacter{0096}{\"o} to easily detect where to problem was but when using [utf8x] the error message remained the same and when using [utf8] there was an additional error: "! Package inputenc Error: Cannot define Unicode char value < 00A0"
Thanks for any help!
I had the same issue with my bibliography. In my editor (TeXstudio), the character U+0096 is rendered as whitespace. For some unknown reason, the line pdflatex reports as containing the offending character is inaccurate.
I solved the problem by running a regular expression search for \x0096 and it found the offending character immediately. Deleting the character and replacing it with a true space fixed the issue.
Incidentally, I tried the \DeclareUnicodeCharacter{0096}{ } fix and it did nothing for me. This could be because the offending character was in the .bib file rather than the .tex file where I placed the command.
I do not think that it is workable way by switching the [utf8x].
Just carefully check your code, particularly the part you copy from somewhere, not type it by your self.
I do have the same problem recently.
I show you How I solve this problem.
I remove the code from the R markdown part by part to find which part caused this problem. Finally, I found the below part that resulted in the error in my code.
### Platform:Affymetrix A-AFFY-2-Affymetrix GeneChip Arabidopsis Genome [ATH1-121501].
I remember I copy this information from webpage. So I delete them and type this part by myself. It can run and generate the pdf file without any error.
To be clear, I show you the difference between the copy version and the version of my typing:
This is just one example I think. I want to point out that it is always problematic when you copy something from an unknown resource file into your code.
Hope this can help you and other people who were frustrated by this problem.

"IO error while decoding Routes.scala with UTF-8" when compiling Play Framework project

When I compile my project, the console will show:
[error] IO error while decoding Routes.scala with UTF-8,Please try
specifying another one using the -encoding option"
What might be the reason for this error?
You might have smart quotes or other Microsoft specific encoded characters in your routes file. This can often happen if you copy and paste from a Microsoft Word document or from the web into your file. Look for “ or ” or apostrophe characters that curl one way or another. Replace them in a programmer's text editor with regular straight quotes and single quotes.

.tmlanguage escape sequences and rule priorities

I'm implementing a syntax highlighter in Apple's Swift language by parsing .tmlanguage files and applying styles to a NSMutableAttributtedString.
I'm testing with javascript code, a javascript.tmlanguage file, and the monokai.tmtheme theme (both last included in sublime text 3) to check that the syntax get highlighted correctly. By applying each rule (patterns) in the .tmlanguage file in the same order they come, the syntax is almost perfectly highlighted.
The problem I'm having right now is that I don't know how to know that a quote (") should be escaped when it has a backslash before it (\"). Am I missing something in the .tmlanguage file that specifies that?. Other problem is that I have no idea how to know that other rules should be ignored when inside others, for example:
I'm getting double slashes taken as comments when inside strings: "http://stackoverflow.com/" a url is recognised as comment after //
Also double or single quotes are taken as strings when inside comments: // press "Enter" to continue, the word "Enter" gets highlighted as string when should be same color as comments
So, I don't know if there is some priority for some rules over others in the convention, or if there is something in the files that I haven't noticed.
Help please!
Update:
Here is a better example of what I meant by escape quotes:
I'm getting this: while all the letters should be yellow except for the escaped sequence (/") which should be blue.
The question is. How do I know that /" should be escaped? The rule for that piece of code is:
Maybe I am late to answer this. You can apply the following method.
(Ugly) In your end regex, use ([^/])(") and in your endCaptures, it would be
1 = string.quote.double.js
2 = punctuation.definition.string.end.js
If the string must be single line, you can use match=(")(.*)("), captures=
1 = punctuation.definition.string.begin.js
2 = string.quote.double.js
3 = punctuation.definition.string.end.js
and use your patterns
You can try applyEndPatternLast and see if it is allowed. Set applyEndPatternLast=1 will do.
The priority is that earlier rules in the file are prioritized over later rules. As an example, in my Python Improved language definition, I have a scope that contains a series of all-caps constants used in Django, a popular Python web framework. I also have a generic constant.other.allcaps.python scope that recognizes (just about) anything in all caps. Since the Django constants rule is before the allcaps rule in the .tmLanguage file, I can color it with a theme using one color, while the later-occurring "highlight everything in all caps" only grabs identifiers that are NOT part of the first list.
Because of this, you should put your "comments" scope(s) as early in the file as possible, then write your parser in such a way that it obeys the rule I described above. However, it's slightly more complicated than that, as I believe items in the repository are prioritized based on where their include line is, not where the repository rule is defined in the file. You may want to do some testing to verify that, though.
Unfortunately I'm not sure what you mean about the escaped quotes - could you expand on that, and maybe add an example or two?
Hope this helps.
Assuming that / is the correct character for escaping a double quote mark, the following should work:
"str_double_quote": {
"begin": "\"",
"end": "\"",
"name": "string.quoted.double.swift",
"patterns": [
{
"name": "constant.character.escape.swift",
"match": "/[\"/]"
}
]
}
You can match an escaped double quote mark (/") and a literal forward slash (//) in the patterns to consume them before the end marker is used to handle them.
If the character for escaping is actually a backslash, then the tricky bit is that there are two levels of escaping, for the JSON encoding as well as the regular expression syntax. To match \", the regular expression requires you to escape the backslash (\\"). JSON requires you to escape backslashes and double quotes, resulting in \\\\\" in a TextMate JSON grammar file. The match expression would thus be \\\\[\"\\\\].