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).
Related
My Rest-Application delivers data in correct encoding when running under Eclipse. But when I start the application as executable jar on a Windows System, my special characters are broken.
What am I missing?
Eclipse
Eclipse's encoding is set in preferences->general->workspace, which whould by default be inherited from the OS (cp1250 on windows).
When you create a "Run as" task, it also stores it. So if you update eclipse's setting, make sure you re-create your "run as" task. You can see the actual value used when launching your application: Run configurations... -> Your Run task -> Common tab.
You can also force an encoding in eclipse.ini by adding -Dfile.encoding=AnotherEncoding at the end.
Command line
When launching from the command line, it takes the system default value, which would be cp1250 on whidows.
You could print the encoding at the very first line of your program, just to see: System.out.println(System.getProperty("file.encoding"));
To specify an encoding from the command line: java -Dfile.encoding=UTF-8 yourApp.jar
See also
Take a look at this too: https://stackoverflow.com/a/14867904/641627
This indicates a problem with your code. Your code is currently
depending on the default platform encoding, and doesn't work if that
encoding is not "UTF-8". therefore, you should change the places in
your code which depend on the default platform encoding to use the
"UTF-8" encoding explicitly.
By default projects run in Eclipse that has console output will bring focus to the console window and display the output there.
Eclipse has a Local Terminal option. Is there a configuration that will activate this as the output destination for a running project?
Before upgrading to Neon I was using an ansi plugin for the console, which isn't installing properly in this current version (ansi-escape-console). While it might be a temporary glitch, now is a good time to learn how to use the Local Terminal alternative.
I'm trying to have the ansi escape codes displayed in scripts like:
#!/bin/bash
RED='\033[0;31m'
NC='\033[0m'
printf "Hello... ${RED}This is red highlighted text ${NC}.\n"
Update: I was able to get the ANSI Escape in Console plugin from the Marketplace installed. I still would like to know how to specify the output to the Local Terminal view as an option.
There is a difference between the Console view and the Terminal view.
Console View
The console view is a facility for the output of the applications running in IDE of eclipse (for test and debugging).
Terminal View
The Terminal View is a terminal emulator for access to the local computer's shell.
While I wanted to see the Ansi Color output and other escaped sequences of the IDE console running programs, this is done using the Marketplace upgrade of the ANSI Escape on Console plugin.
I am writing a Perl program that uses curses for output and move the cursor, and color characters. Previously, when I was working under windows I use Komodo it was able to run an external console.
Now I work in Linux environment and use eclipse + epic. If you try to just run the script, it uses the internal console eclipse, which is very cut. You can just run the script using external tool, but I'm interested to debug using external console window. Is this possible?
Unfortunately, use of a File and /dev/pty/1 does not help in solving my problem.
The fact is that in this case it is impossible to get the characters introduced in the console through curses getch(). Always returned 1 instead code of pressed key.
Here is an answer that will take you most of the way (based on post #6 of: http://ubuntuforums.org/showthread.php?t=743131, although since then, in the "Indigo" and "Juno" versions of Eclipse, things have changed somewhat, and this answer is up to date):
Go to "Run -> Debug configurations". Click on the (fourth) "Common" tab. Go to the third frame from top, and there, check-mark the checkbox which says: "File". Enter the file name of the console window you want your output in.
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
Netbeans has this wiki entry on line endings: http://wiki.netbeans.org/FaqEditorEOLs
But it isn't very useful. It just says that you shouldn't develop on different OS and that's that...
In my situation however, I have no power over it. I'm on a windows machine and the PHP app I'm working on needs to end with the UNIX EOL.
There does not seem to be an option to set this for new files. Can anyone tell me where to set this?
Just saw that you can set this as a command-line startup flag: -J-Dline.separator=LF
I haven't tested this myself but I'm looking for ways to bake this into the configs somehow.
Since, a specific plug-in came out: http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=36810
I also like #JimLewis suggestion but I work on Windows with a linux virtual machine thus in some cases the versioning system line ending cannot help.
[update 201709]
I no longer use netbeans (sorry, but I need python support and it's too buggy) and almost no longer develop on windows, but #marinos-an in a comment suggests https://github.com/welovecoding/editorconfig-netbeans which uses a common setting file that can be picked up by multiple editors through plugins. Definitely interesting to try since the settings file is committable!
Have you considered managing the line endings at the version control level? Subversion,
for example, lets you set an "eol-style" attribute with values "LF", "CR", "CRLF",
and "native" (which translates the line endings stored in the repository to whatever
is appropriate for the platform where the files are being checked out, and converts
the other way when you check in.)
Please use following Netbeans Plugin
http://plugins.netbeans.org/plugin/36810/show-and-change-line-endings
fentie's answer solved my problem with line endings, as pasting multi-line MySQL from NetBeans into the MySQL command prompt caused errors.
To pass this argument to NetBeans every time it opens, add it to the netbeans.conf file:
/Applications/NetBeans/NetBeans\ 7.1.2.app/Contents/Resources/NetBeans/etc/netbeans.conf on OS X.
From the NetBeans Mac page under Tips & Tricks.
When I pasted multi-line SQL statements from NetBeans to the MySQL command line client on OS X or a remote Linux server, MySQL would list all possible command choices, give me some strange '> type of prompt and I was forced to hit Ctrl+C and log back into MySQL again.
For my Netbeans 12.6
I found a pluging called "Change Line Endings on Save"
https://plugins.netbeans.apache.org/catalogue/?id=31
more details are there
https://github.com/junichi11/netbeans-change-lf
once pluging installed you can configure EOL in there:
Tools > Options > Editor > Line Endings