My settings are UTF8 for IDE-Encoding and project encoding but when I evaluate an expression, I get the following result :
Any Ideas ?
Related
My question is similar to Printing Unicode from Scala interpreter and scala default encoding in windows shell, but goes into more detail WRT different behavior of Scala (version 2.12.2) vs. Groovy (version 2.4.7).
I have the following code snippet (which happens to be both valid Scala and Groovy code):
println("└─ ");
println("├─ ");
println(System.getProperty("file.encoding"));
When running the scala interpreter on it the Windows terminal (all of cmd, PowerShell, Git Bash / mintty) it shows
$ scala a.scala
??
??
Cp1252
However, running the exact same code through the groovy interpreter it shows:
$ groovy a.scala
└─
├─
Cp1252
My understanding from reading the answers to the linked questions is that the output is (solely) dependent on the value of the file.encoding system property. If so, how can the output be different between Scala and Groovy then if the used file.encoding is the same?
Edit: This answer seems to confirm it's an issue with the encoding used by the Scala compiler to read the source code file, which seems to default to whatever file.encoding is set to, even if the file clearly is UTF-8 encoded. I'm still wondering why Scala is not as smart as Groovy here...
Edit 2: I can work around the issue by running
$ scala -Dfile.encoding=UTF8 a.scala
└─
├─
UTF8
but still this dos not answer the question why Groovy does get it right despite file.encoding being set to Cp1252.
I think it's connected with different source encoding during compilation step
try this instead of println("├─ ");
println("\u251C\u2500");
or for groovy there is a parameter --encoding to specify the encoding of the source files.
quite sure for scala should be the same parameter
finally better not to use non-ASCII characters in your source code.
I used this service to convert chars (but any ide can do it for you)
My environment: Rails 4.2.4 Ruby 2.0 & SQL Server 2014 with a collation of SQL_Latin1_General_CP1_CI_AS at the database level.
I got an error
incompatible character encodings: UTF-8 and ASCII-8BIT
when the view found in the database some special characters like ç, á, é, etc.
I've had tried some configurations that I read but nothing worked.
I tried this in the view:
# encoding: utf-8
In the enviroment.erb:
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
In the application.rb:
config.encoding = "utf-8"
I tried in view:
<td><%=h role.description.force_encoding("ISO-8859-1").encode("UTF-8") %></td>
It worked correctly but this way is very difficult. I want something that run in all project, like on models for example
I tried on Role class:
self.column.force_encoding("ISO-8859-1").encode("UTF-8")
but not recognize the command
Could someone please help me?
Tanks!
Ale
I solved my problem, finally.
A colleague gave me a tip installing the
tiny_tds
gem and ran properly without any of the settings listed above, just set up the database.yml
development:
adapter: sqlserver
mode: dblib
database: MyDataBase
dataserver: MyServer
Previously I was using ruby-odbc gem
thanks!
When I create a script file and load it from the console with:
load '//192.168.0.0/Mağaza/script.rb'
I get 'Invalid component file' error for:
someModel = Sketchup.active_model.definitions.load '//192.168.0.0/Mağaza/Definitions/model.skp'
But when running the code directly in console, it works.
Any idea why?
DefinitionList.load is a completely different method from Ruby's load.
To load a component from a URL you need to use model.definitions.load_from_url:
http://www.sketchup.com/intl/en/developer/docs/ourdoc/definitionlist#load_from_url
After two days, I figured out that the problem was the encoding of 'ğ' in the folder name (mağaza). I tried ANSI and UTF-8 encoding in my script file but nothing changed. But when print the path name in the console, it turned out that the character was not encoding properly.
I tried to run my rails project on jruby 1.6.7 in 1.9 mode.
I've got troubles with encodings in slim templates and mongodb (with mongoid)
template:
incompatible character encodings: UTF-8 and US-ASCII
and in mongo I see something like Ð\u0090лекÑ\u0081андÑ\u0080
I've tried to solve thus problem by adding in Application.rb
config.encoding = "utf-8"
also I've put
$KCODE = 'u'
Encoding.default_external = Encoding::UTF8
Encoding.default_internal = Encoding::ASCII_8BIT
I've trying to put
#encoding: utf-8
in templates.
Even trying to add in JRUBY_OPTS
-J-Dfile.encoding=UTF8
this all does not helped.
I use jRuby 1.7.0.preview1 on Heroku and I had problem that all my responses ware us-ascii encoded. So I added following configuration to "JRUBY_OPTS". And it helps - my code returns UTF-8 responses.
JRUBY_OPTS: --1.9 -J-Xmx400m -J-Dfile.encoding=utf8
A Sprockets::EncodingError exception is thrown when I include a file with characters that are valid utf-8.
The line in question is:
* Copyright (c) 2010 - 2011 Johan Säll Larsson
If I replace the ä character, the problem goes away, but I don't want to have to remember to edit this vendor file everytime I update it.
How can I fix this?
I found the solution via the comments on this Sprockets issue:
I simply saved the file as utf-8, (TextMate has an option to do this when you chose 'Save As'), and the problem went away.
The commenter #shedd also created a useful rake task to find assets which are not encoded properly.
This is fixed in trunk. All files use utf-8 without BOM.