MinGW-W64 Encoding with Clion - encoding

Windows 10 Jetbrains Clion 2018.2.1
MinGW-W64 Encoding
input[1] :
std::cout << "가나다라 abc" << std::endl;
output[1] :
媛?섎떎??abc
Settings > Editor > File Encodings
I can solve with Path setting: EUC-KR, but only configured file only. I have to configure Encoding setting every each project, every each file.
I found when using CMD, chcp 65001 works, but clion's cpp output cannot manage like that.
VM option :
-Dconsole.encoding=EUC_KR
-Dconsole.encoding=EUC-KR
-Dconsole.encoding=UTF8
-Dconsole.encoding=UTF-8
-Dfile.encoding=EUC_KR
-Dfile.encoding=EUC-KR
-Dfile.encoding=UTF8
-Dfile.encoding=UTF-8
I tried them all, each by each, but they does not work.
cygwin basically works well, but mingw-w64 doesn't work well. I searched for hours, but I couldn't find any answer.. :(
Thank you for reading..

Unfortunately, the Windows console only supports standard characters. If you try to print a special character, it will appear abnormally.
Windows cmd uses a simple ASCII table, while Windows uses an extended ANSI table. The 128 first characters are identical, so you can use them only.

Related

NetBeans 11 and Encoding characters

Now I download Apache NetBeans 11 and after that, I CLONE my Git PHP Repository to Windows Folder, If I open HTML files via Notepad, everything is ok, but when I open it via NetBeans, I got wrong characters interpretation like this:
BAD
Ăšvod
RIGHT
Úvod
How can I solve it to use UTF8? When I open a file in example via PSPad Editor I see the encoding is UTF8, but the format is UNIX, not DOS, maybe this cause a problem
Edit:
When I use Netbeans 8.2 Characters are ok
Any sugestions?

Can't make Eclipse (Luna) PyDev console use UTF-8

In Eclipse Luna (4.0.4) / Python 3.4.1 I can't get the PyDev 3.6.0 console to work with Unicode despite having tried several recommended corrective steps.
I attempted this example in Dive Into Python 3: http://www.diveintopython3.net/files.html
If I do the example's a_file.read(), the PyDev console displays:
'Dive Into Python \u662f\u4e3a\u6709\u7ecf\u9a8c......' instead of 'Dive Into Python 是为有经验的程序员编写的一本...'
If I paste the Chinese characters into the PyDev console ala cstring = '是为有经验的程序员编写的一本', then in the console type "cstring ENTER', I again get '\u662f\u4e3a\u6709\u7ecf\u9a8c...'
If I then try print(cstring), I get the following error:
Traceback (most recent call last):
File "", line 1, in
File "C:\Python34\lib\encodings\cp1252.py", line 19, in encode
return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-13: character maps to
I don't know what do do with that information. The cp1252.py bit is at the heart of my confusion because I've told Eclipse and PyDev to use UTF-8 in every place I can find to do that, beginning with the information in the following:
Printing Unicode in eclipse Pydev console and in Idle
However, I cannot modify "site.py" as described in those steps because [EclipseInstallDir]/lib/site.py does not contain "encoding = ".
I can't figure out what to do next.
For regular runs:
The problem there is that the PYTHONIOENCODING is overridden by PyDev based on the encoding you used in the run configuration (which is the encoding used by the console view too -- so, it'd make no sense having a PYTHONIOENCODING with a value and the allocated console in the PyDev side with another value).
You can change the encoding you're using for a run configuration in:
Run > Run configurations > common > encoding.
By default it'll use the encoding of the file being launched (you can change the default encoding for the workspace in general > workspace > text file encoding).
For interactive console runs:
For interactive console runs there's currently no API to change the encoding in the java side, so, one has to start Eclipse itself in a VM that uses UTF-8 by default... In practice, this means that you have to add:
-Dfile.encoding=UTF-8
to the vmargs of Eclipse in eclipse.ini (and in this case it's also recommended to set the PYTHONIOENCODING environment variable in the related interpreter and set it to UTF-8).
Found it! (At least for Python 3.4.1, Eclipse Luna 4.0.4, PyDev 3.6.0.)
In Eclipse, in Preferences —> PyDev —> Interpreters —> Python Interpreter, in the Environment tab, I added the environment variable PYTHONIOENCODING and specified its value as utf-8.
The PyDev Interactive Console now properly displays the aforementioned Chinese characters (and Thai characters, too).

Encoding problems across Eclipse, Mercurial, Windows and Mac OS

During my CS studies, we have a good bit of group assignments. We program in Java using Eclipse. We (or atleast i try to get them to) share code using Mercurial and BitBucket. I'm running Mac OSX 10.7 and the others are running Windows 7. We often have problems with the encoding when we share code. Danish characters such as æ, ø and å is often a mess.
What settings should we run across our eclipse setups to ensure that the encoding will be the same (and what encoding would be preferred?) On Windows, Eclipse defaults to Cp1252 and on MacOS it defaults to MacRoman. I've been trying to get everyone to use UTF-8, but code they previously wrote (in Cp1252) wont show correctly, so they are forced to switch around a lot, which usually ends up in them defaulting back to Cp1252 and forgetting about it when they submit code to a shared repository.
For me it works to use the standard encoding (Cp1252) in Eclipse on Windows and to tell Eclipse on Mac to use the encoding ISO-8859-1. On Mac I configured this for my whole workspace in the settings (under General --> Workspace).
Encode old 1250 texts into UTF8 by hand and use only these versions
Speaking from experience, I believe the best solution is for everybody to use UTF-8, that can represent any Unicode character.
The workaround CP1252 & ISO-8859-1 is not perfect, some characters are not compatible between them. Moreover, most IDEs default to UTF-8, if someone must have the trouble of changing Eclipse encoding settings, I believe it should be Windows users.
So after much headache using CP1252 & ISO-8859-1, I decided to change all my files to UTF-8. In case someone is interested, you can do that on Unix with a command like this, that will change all files in the current directory and its subdirectories:
find . -name "*.java" -exec sh -c "iconv -f ISO-8859-1 -t UTF-8 {} > {}.utf8" \; -exec mv "{}".utf8 "{}" \;
Since you are informing the original encoding, iconv will be able to convert without messing with accents and special characters.
Then ask everybody to create a new workspace, configure all encoding configuration on Eclipse to UTF-8 (Windows users) and import the project again.

Eclipse CDT using MinGW does not output in console

I have a Windows 7 64-bit PC and I am trying to install a free C++ IDE, so I chose to install Eclipse Helios with CDT.
For g++, make and gdb I installed msys and mingw according to this tutorial:
http://wiki.wxwidgets.org/HowTo:_Install_MSYS_and_MinGW_for_use_with_Eclipse_CDT
The versions are:
make: GNU make 3.81
g++: 4.5.0
gdb: 7.1
So it should be compatible with my 64-bit CPU.
However when I try to run a very simple program with eclipse, I see nothing on the console. The source code is:
#include <iostream>
using namespace std;
int main()
{
int i;
cout << "Enter an integer: " << endl;
cin >> i;
cout << endl << "i is " << i << endl;
return 0;
}
The build is fine and when I launch the .exe with command (windows console) the behavior is as expected.
But with the Eclipse console I see nothing with run and with debug the output is just:
"Enter an integer: ", then when I type in a number and hit enter it does nothing.
Does anyone know how to fix this please?
Thanks,
Guillaume
PS: I use the toolchain "Linux GCC", with "MinGW GCC" I have nothing at all in the console.
This worked for me on 64-bit install of Eclipse on Windows 7 using MinGW:
Right-click on your project. Select "Properties".
Select the "Run/Debug Settings" Property on the left of the new window.
In the right window, click on your executable to highlight (ie - Test.exe) and click "Edit".
In the Environment tab, hit "New"
Name: PATH
Value: Path to your MinGW bin directory. (For me this was: C:\devcore\MinGW\bin)
Click "OK" on all windows to close down.
Try running again, it should print output to the screen.
You need to set up linker
I am using MinGW.
Follow below steps.
Goto Project > Properties > C/C++ Build > Settings > Tool Settings (Tab) > MinGW C++ Linker (Option) > Add Command (g++ -static-libgcc -static-libstdc++) (default command is only g++)
purlogic's solution works.
Instead to set that for every project, I found it can be set globally:
In Window -> Preferences-> C/C++ -> Build -> Environment
Add a variable for your compiler. e.g, I added:
MINGW, with value "C:\MinGW\bin"
This console bug has been noticed in 64-bit versions of eclipse:
http://www.eclipse.org/forums/index.php?t=msg&th=197552&start=0&S=2a2b64e1f1404705c0214976bd477428
A workaround is to install the 32-bit eclipse
I ran into the same problem, because of multiple gcc installations on one PC. But Greg's solution only worked partly for me.
In my case the flush was not done in the application explicitly. While C++ programs often use std::cout << ... << std::endl where the endl does a flush, my program used actual C-output such as the usual printf. The printf could be seen directly when starting the program in the cmd-window. However in eclipse console they were missing. Hence a
fflush(stdout);
after the printf did the thing for me. That could be an issue within the eclipse console implementation. I guess that's why fixing the Path did not work for some people here.
An alternative solution instead of setting the PATH within the "Run" settings is to start the whole eclipse using a batch file, which looks essentially like this:
set PATH=<mymingwlocation>\bin;%PATH%
start <myeclipselocation>\eclipse.exe
Then any run configuration would use the correct MingW location by default. That might also fix other problems that could arise from using the wrong gcc.
Have you tried to execute the eclipse.exe with administrator privileges ?? it worked for me !
Had this issue on 64-/32-bit eclipse Kepler CDT to work on a openCV/wxWidgets tool, Win7, using MinGW to build.
If anyone comes across this while having this issue and are working with openCV you will already know that there are many outdated openCV building/installing instructions all over the internet.
One I had was to go to Build Settings -> Linker -> Miscellaneous and inside of the Linker Flags text entry box, type in
-Wl,--subsystem,windows -mwindows
However, this disables cout from outputting to a command line terminal in windows.
Doing some more digging this looks intentional, apparently the -mwindows involves directing STDOUT away from a command line specifically to a GUI-like application.
Also, removing -mwindows and just leaving in -Wl,--subsystem,windows accomplishes the task of redirecting STDOUT anyway away from the command line all the same.
Now mind you, I haven't built up anything yet outside of a hello world program involving wxWidgets and openCV, so I am not at the point of doing a cout into a part of a GUI so I don't know if that functionality would now be broken or if it would print out to the GUI object, as well as a command line terminal.
Or set the linker option -static.
Works for me at least.
Add PATH variable (PATH="your MinGW/bin directory path") into your C++ project by Run -> Run Configurations ->in Environment Tab

NetBeans charset problem. Linux -> Windows

I have problem with charset in my NetBeans on Windows when I open files, which were editting in NB on Linux by my coworkers.
I guess it should be unicode in both.
What I should to do to resolve this problem?
I can find proper option.
I use frensh and changed the netbeans encoding to Iso-8859-1 and it worked for me.
tried UTF-8 before didn't do it
my symptoms were as follows:
- a website hosted on linux and developped by another dev
- downloaded on my windows 8 , netbeans 8.0 beta or 8.1
- when opening a file for the first type it was saying "cannot option safely..." if chose Yes all my frensh special chars were messed up
-Hicham
right-click on Project -> Properties -> Sources -> Encoding
for maven project, put project.build.sourceEncoding in pom->project->properties
We had the same problem with Eclipse because of mixed Windows and Linux developers. If you use Java you have 3 options:
change to Unicode charset. Though we couldn't do that with Eclipse on Windows, maybe it works out for you. Linux should be usually on Unicode already.
change to Iso-8859-1 on Linux, seems to be compatible with CP1252
use the tool native2ascii to change non-ASCII-characters in strings to their explicit unicode representation (IMO this is the most robust solution, though it's Java only I guess)
The most easy way to solve this is by a terminal command
$ sudo sh netbeans-8.0.2-linux.sh