I recently started to use Vim, but I'm having some encoding problems, and I'm not really sure if it's a Ruby problem or a cmd/powershell problem, but Ruby is not accepting CJK characters with gets, and sometimes printing isn't working properly.
gets error
The following images are from cmd and powershell, it shows how p, puts and print print it (I don't know if it is important tho), and the code is just var = gets
printing "error"
In powershell, p printing doesn't work if I use CJK (apparently it doesn't work with UTF-8), but in cmd all works perfectly
What I already tried:
Set cmd and powershell encoding as UTF-8: In cmd it worked, but in powershell I don't seems to work. I tried $PSDefaultParameterValues['Out-File:Encoding'] = 'utf8' and $PSDefaultParameterValues['*:Encoding'] = 'utf8' as in this answer
Changing cmd and powershell font: As you can see in the images, the font supports CJK (MS Mincho)
Open cmd with UTF-8: I'm using cmd /K chcp 65001 to open cmd
Other informations:
Windows 10
irb(main):001:0> RUBY_VERSION
=> "2.7.3"
irb(main):001:0> Encoding.default_external
=> #<Encoding:UTF-8>
Related
I'm encountering the issue of having jshell not displaying non-english letters on MS-Windows. On Linux and Mac jshell behaves correctly.
In a DOS window, I try to enter Greek letters, e.g.:
jshell> var s = "Γειά"
but I can only see
jshell> var s = "????"
I thought that it had to do with the locale or character set.
C:\> chcp
437
so I changed it to UTF-8
C:\> chcp
65001
hoping that this would fix the problem, but alas. Please note that in DOS (outside of jshell) I can type Greek letters without an issue.
Even the JShell from inside NetBeans doesn't like non-English letters:
[1]-> var s = "Γειά σου";
| s ==> "???? ???"
So I was wondering if there is some way to set the encoding in JShell itself.
Please note that this behaviour exists only in JShell on Windows. The OS locale has been changed to support the Greek language. However, JShell doesn't want to comply.
Has anybody encountered similar behaviour trying to display letters in JShell Windows from another alphabet?
try
chcp 1253 && jshell
Is it possible to display chinese characters in command prompt? if so what are the settings.
If you need to read simplified Chinese (GBK) which is code page 936
Enter the following command in the dos prompt
chcp 936
I guess it's some settings in CMD
the default CMD doesn't support the unicode characters(including all other languages than English)
I don't know how to do it
But you can search about it "make CMD support unicode"
I want to have a lambda (λ) symbol as my prompt in GHCi (7.8) on Windows 7, so I set up my .ghci file as
:set +m
:set prompt "λ: "
:set prompt2 " | "
And I set my console font to Lucida Console since it's supposed to support Unicode, but when I load up GHCi, it looks like this instead
How can I get Windows to recognize the λ symbol properly?
Using > chcp.com 65001 worked with GHCi but opening other text files with Vim after setting that encoding returned garbled text.
Add the following to your %USERPROFILE%\.ghci. Instead of changing the encoding, you can use the Unicode escaped lambda \x03BB:
:set prompt "\x03BB: "
If %USERPROFILE%\.ghci does not exist, create it first before making the change.
This is actually quite a simple fix, just run the following command before starting GHCi:
> chcp.com 65001
This sets Window's encoding to the 65001 code page, which lets the λ get displayed properly:
This will also let a lot of other Unicode characters be displayed properly in cmd.exe and other Windows shells (such as Cygwin bash), but Windows' Unicode support is still not perfect, and some fonts don't support many of the characters. Luckily, λ happens to be a supported character so we can all have the classic GHCi prompt.
Using Răzvan Flavius Panda's answer, I decided to make a configuration file that had three flags for setting the prompt. The reason for this is prompt-cont is for GHCi versions >= 8.2.0, whereas prompt2 is for older GHCi versions.
I had a look at a short tutorial about configuring GHCi to try and find out where to put the configuration file. The site says that GHCi reads configuration files in the following order:
./.ghci (Local configuration file.)
Depending on your OS:
*nix: $HOME/.ghc/ghci.conf
Windows: C:\Users\<name>\AppData\Roaming\ghc\ghci.conf
$HOME/.ghci (Possibly *nix only; didn't work for me.)
I chose the second option.
C:\Users\Edwin\AppData\Roaming\ghc\ghci.conf:
:set prompt "\x03BB> "
:set prompt2 "\x03BB| "
:set prompt-cont "\x03BB| "
Explanation:
\x03BB stands for λ.
prompt is the main prompt. So it'll be "λ> ".
prompt2 is for a secondary prompt (I haven't seen it yet). So it'll be "λ| ".
prompt-cont is the same as prompt2, and is a replacement for prompt2 in GHCi 8.2.0.
This question already has answers here:
How to use unicode characters in Windows command line?
(19 answers)
Closed 6 years ago.
I've tried to display UTF-8 in the win7 cmd. Currently, I'm using the standard font because as I see with the mysql.exe, it works fine with the characters I'm working with (currently the german umlauts "ßäöüÄÖÜ"). Also, with another font, the same characters appear.
But the output of my PHP script displays garbage, e.g. 'ß' for 'ß'. When I pipe the output into a file and open it up with Notepad++, it says the encoding is UTF-8. In php.ini I set UTF-8 as the encoding as well as in the connection to the mySQL database, and in the database itself UTF-8, too.
In CMD I tried so far to set the code page to 65001, but nothing changes.
edit: my PHP script is saved as UTF-8 as well
It seems with latin1, my desired characters can be displayed too and actually it works. But there has to be a way to do it in UTF-8? I can't convert everything to latin1
This question has been already answered in Unicode characters in Windows command line - how?
You missed one step -> you need to use Lucida console fonts in addition to executing chcp 65001 from cmd console.
I'm trying to print out some Unicode characters:
# encoding: utf-8
puts "ử ậ ắ ặ ố ồ"
If I run it through Powershell, this is what I get:
If I run it through cmd, this is what I get:
If I run it in Eclipse (with Aptana Studio 3 plugin), this is what I get:
Is it a problem with my system/software or is it Ruby's problem? How can I get it to work?
It works on Ideone though: http://ideone.com/PdycKH
Ruby supports it no problem, and setting the formatting at the top of the file is the way to go.
The issue is the display via the command line window. You need to use both a font and character page that supports Unicode display.
See this question regarding doing this in the Windows command line.
About the chcp command
I figured it out:
For cmd and Powershell, I have to change the font (I changed to Consolas)
In Eclipse, I have to change the encoding: go to Run/Run configurations, select the Common tab, change the Encoding to Other: UTF-8