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

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.

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.

I keep getting syntax errors with my new vBulletin Install

Here is one of many errors I keep getting.
Parse error: syntax error, unexpected 'Database' (T_STRING) in /home2/craven/public_html/forums/core/includes/config.php on line 39
Make sure, you use the correct singlequotes in the config file.
These are correct: 'string', "string"
These are wrong: ´string´, string
You could try to replace all singlequotes with the correct double-quotes, just in case there is something funky going on with encoding in your file.
Also, make sure there are no spaces or newlines between the $config[...] definitions which might break the syntax parser.
Maybe check if the config.php file has the correct encoding, UTF-8 or any latin encodings if you're using european special characters for example. You can use a text editor like Notepad++ to check/modify the file encoding and re-upload the updated file afterwards.
If it still fails, you need to provide information about your webserver system, like the PHP version.

How to use unicode characters in Eclipse File Search?

We have some XML file that contains some invalid character, and the program says neither which file it is, nor which line number or character offset. It would be a few seconds work to fix the problem if I could just search for exactly that character, but I cannot find how to express a Unicode character in the file search (or at least I assume so, since the search returns nothing).
Neither 0x1e nor \u001e seem to match anything.
[EDIT] I mean, I can still change the code, and eventually find which file it is by catching the Exception, and using some kind of script/tool to find where exactly the character is, but I do believe it should be possible to search with Unicode in Eclipse, and that is what I am asking in this question.
It may be a problem with the character encoding.
As you're going to need to perform a global / site-wide search to find the , you'll probably need to set the global text file encoding:
Preferences -> Workspace -> Text file encoding
This option may be under the 'General' section in Eclipse, depending on your setup and installed plugins etc.
Ensure that the encoding is set to UTF-8.
You will also need to escape the unicode character sequences, like so:
\u2665
(which I see you have tried)

Is Localizable.strings required for the root language of an app?

As we're enabling our (English) application to be localized, we're replaced all in-line strings with NSLocalizedString() calls. Since all of our English strings are all there in-line with the code, e.g. NSLocalizedString(#"OK, #"OK button in a message box"), is there any reason we need the English version of Localizable.strings? When we try removing the strings from the English Localizable.strings, the program seems to work fine. Just wanted to double check if there was some side-effect to not having that around. Thanks, alex
One of the main points of using the NSLocalizedString() macro is so that your programming code can be parsed with the genstrings command-line tool to generate the corresponding Localizable.strings file(s) (see Resource Programming Guide: About the String-Loading Macros and Using the Genstrings Tool to Create Strings Files).
That Localizable.strings file then serves as a starting point for your translators, to use to translate to another language. Without that file to work with, your translators would basically need access to your source code in order to see all the strings you want to use (which kind of defeats the purpose).
Yes, your English version works fine right now, since if a localized version of the string you try to get in code –– for example, NSLocalizedString(#"OK", #"") –– cannot be found in a .strings file, it simply uses the #"OK" string that you passed in.
Another reason why you should likely be keeping the English Localizable.strings is that you should generally try to avoid using high-ASCII characters in your code, but should use the full range of available characters in your actual user interface. For example, you may not want to put the following characters in your code, but would want to use them in your user interface:
… (horizontal ellipsis) (U+2026)
“ (left double quotation mark) (U+201C)
” (right double quotation mark) (U+201D)
‘ (left single quotation mark) (U+2018)
’ (right single quotation mark) (U+2019)
So in code, you'd do something like this:
NSLocalizedString(#"Add Bookmark...", #"")
and then in your .strings file (which is UTF16, so this is fine):
"Add Bookmark..." = "Add Bookmark…";
It's not recommended to use the words as keys, if you want to change that Ok for something else and you have any other Localizable.strings, you will have to edit every single of them to update the Okkey.
Surely your translators will want your Localizable.strings file to work from. And want it to be ALL the strings.
(It is true that the system will fall back to the key, but relying on that seems like bad practice. And you'll find it more reliable to use proper punctuation in a Unicode file, which source code seldom is.)

Double quotes inside Scala block comments?

I found a pretty weird thing that I cannot write double quote inside Scala block comment(/**/), I got an error said:
IO error while decoding xxxx.scala
with UTF-8
If I change the double quote to single quote, it compiles fine.
I am using IntelliJ IDEA Community Edition 98.231 with a nightly build Scala plugin.
So what problem could it be?
Posting this as an answer so that the question can be closed. All kudos to #retronym.
I would guess you have a unicode curly quote. If you want to use unicode, i recommend to add -Dfile.encoding=UTF-8 to the IntelliJ vmoptions file, and set your File Encodings in your IDE settings to UTF-8.