How to set default system file encoding in IntelliJ IDEA - file

I want IDEA to use whatever default system encoding is, instead it uses whatever is set through Settings > File Encodings. Which is set to UTF-8.
My application runs fine in Eclipse, which uses default system encoding on windows, but it is having trouble reading some xmi files when running the application through IDEA.

You can select system's default encoding from the same drop down:

Found it in File->Other Settings->Default encoding: http://ufasoli.blogspot.ru/2013/10/intellij-change-default-encoding-for.html

Related

SSMS 'script as' is saving as utf-16

When I check my default SSMS file format it is Windows 1252, and opening a saved script inside VSCode is showing me it is UTF-8.
However, when I do a 'generate scripts', all I get is options for 'unicode' and 'ascii'. When I save as unicode it is saving as utf-16 and causing havoc with git. Saving a script using file/save as is fine.
I'm no expert on code pages/encoding but I am presuming saving as 'ascii' really is just ascii and will lose any non-ascii characters that are valid in UTF-8
How do I change this 'script as unicode' from utf-16 to 8, or if that is a daft question, get it to save using the default option I have for standard files?
I'm using version 17.6 of SSMS
thanks.

Fix Japanese character issue in unix box

Our company build process uses gradle and copies over the deliverables including sql file to a shared drive. Unix boxes can refer to these paths and then uses a shell script. The shell script invokes the db2 command line utility to run the sql files in the corresponding environment's database.
This works pretty well. However I have hit a wall where we are updating japanese characters in the sql file. When I download the file from the browser and inspect the file, I can see the characters properly. However, in the unix box, I can see that the content in the sql file looks pretty different. I used cat, more and vi to view the contents of the file. Value of the LANG environment variable is C. I see the environment variable set is TERM=XTERM. So I think xterm is the terminal evaluator.
LANG=C
When I run the command in the linux terminal window-
locale charmap
I see the encoding as ANSI_X3.4-1968. UTF-8 is one of the possiblities but that is not set in the box I think.
When I run the command in the linux terminal -
file -bi 1.sql
I see the charset encoding of the file as UTF-8.
When we run the shellscript which invokes the db2 command line utility, it inserts whatever I can see in the unix file and not the actual japanese characters.
I tries searching for options as to what could go wrong. Please find below my analysis -
When I run the sql from the Aqua Data Studio, data is inserted properly. So there is no issue with the actual database setup or the table configuration.
There are some other xml files in the shared path which have japanese characters. In unix box, I again see the distorted characters as I see in the sql file. When these xml files get copied to the reporting server, they work fine and the data is shown properly in the pdf.
So my line of thinking is that there can be some way I can specify in the db2 command line utility to use the correct character set and that should work fine. But I am unable to find anything useful on the internet.
Now there are chances that there is something small which I am not able to figure out. Hence I will request you to help me in this regard. This is not very critical as we can always leave the automated process of deployment and sql insertion , and instead go with the manual insertion by giving the scripts to the DBA. However this is highly discouraged.
Do let me know if you could help me with this regard. Just FYI, I unzipped the war produced after the gradle build (from the jenkins server). I can see the file properly in the notepad++. Do let me know if you need any other info.
If the Japanese characters do not render correctly in cat or more in your terminal window then it means that the LANG variable has the wrong setting. In your case LANG=C is not suitable for Unicode.
Some terminal emulators such as Putty, need to have the translation set to support UTF-8 and that may not be default - otherwise Unicode characters can render incorrectly on screen.
The correct LANG setting depends on your country, on which locales are installed in Linux, and also on the target database territory and codepage and Db2-server operating-system (i.e. Db2 for Z/OS , or i-series, or Linux/Unix/Windows). Sometimes you have to install additional locales if they were not installed by default, it depends on your Linux distro , platform, and version and installation policies.
The solution is normally to ensure you set the LANG variable correctly before you connect to any Db2 database. It's wise to assert such things in configuration checks that get automatically run by scripts. You get the correct value for LANG from the Db2 documentation, and that depends on your Db2-server operating system and version and your knowledge of the target database encoding and territory (or CCSID of the target database/tables/columns/tablespaces etc). For example, if your Db2-database lives on Linux/Unix/Windows, look at this page. Other pages exist for Db2 for Z/OS or i-series.
Once you change the LANG variable ( export LANG=...), again verify that more or cat renders the Japanese characters correctly. If you are already connected to the database, changing the LANG has no effect, so remember to disconnect first. Test the LANG values until the Japanese characters look correct, and only then try the Db2 connection and examine the new behavior.

Unreadable characters in a file on a remote server when viewing in a browser

I have to work with a text file on a remote server. The file can be accessed by a direct link using any browser, in the form http://server.school.com/files/people.all (not a real link, since the access requires a password). When I view it in Firefox some of characters are unreadable for example: 'José Luis Paniagua Sánchez'. I have a few questions.
Could the issue be caused by incorrect settings of my browser or could there be a problem with the file itself?
Is opening a file in a web browser and copying the entire content to a text editor using copy/paste inherently different from downloading the information with a script? Could it affect the encoding of the data?
Thanks.
Select in the browser the encoding, UTF-8 likely. Firefox: View - Character Encoding. The problem is that the file does not specify the encoding of the file (or specifies a default encoding).
A binary download, like downloading an image file (with which you could try), should keep the file as-is.
Cut-copy-paste using the right encoding in the browser should work for UTF-8.
Assuming it is indeed UTF-8 (multibyte sequences for special chars), and you are working on Windows (which is single-byte), you'll better use a programmer's editor like NotePad++ or JEdit, both free. They can set the encoding explicitly, and even convert.

Mercurial: which config property controls the encoding of file contents?

Is there a dedicated Mercurial configuration property which specifies the encoding of file contents and hence should be used by a Mercurial client to properly display a file?
I've found web.encoding which does not seem to mean exactly what I'm looking for. Also, Google gave some results for ui.encoding as well, but I couldn't find any hints in the reference.
Mercurial is not concerned with the encoding of the files you put in your repository: Mercurial is happy to store files with any encoding (or maybe not particular encoding at all).
This means that you can add files with UTF-8, Latin-1, or any other encoding to your repository and Mercurial will check them out exactly as they were when you added them.
The encoding of each file is not stored anywhere in Mercurial and it is up to the client to recognize the encoding (perhaps based on file content where it makes sense, e.g., for XML files).
For a Mercurial desktop client (as per your comments below) I suggest looking at the file content:
Can you decode it at UTF-16?
Can you decode it as UTF-8?
Are the NUL bytes in the file? Then stop and declare it to be "binary".
Fallback on a Latin-N encoding such as Latin-1 for Western Europe.
The UTF-16 and UTF-8 encodings are nice since they are structured and this makes it possible for you to detect that a file isn't valid UTF-8 encoded, say. The above list is written with a European perspective — you should probably also consult someone with knowledge about Shift JIS and other encodings used in Asia.
In any case, I would only expect a Mercurial client to do a best effort attempt at showing me a file with an encoding other than ASCII.
Some alternative interpretations of your question:
If you're really asking about how to make your files look "correct" when you view them in hgweb, then it's a matter of using a consistent encoding in the repository and setting `web.encoding.
If you're really asking how to ensure that text files get the OS native line ending character on different platforms (\n on Unix, \r\n on Windows) when take a look at the eol extension that comes with Mercurial.
No. Encoding (charset) is property of file in repository

Opening a file with the default viewer on Linux

I am working at an OS independent file manager (mostly Windows and Linux), and I am wondering if there is a Linux way to open a file in its default viewer. For example, open a html file with Firefox, an .avi with vlc, and so on.
On Windows, there is a function ShellExecute() that does that, but my understanding is that on Linux it is not that simple, and each desktop environment has a specific way.
I would appreciate any help with this.
You could use xdg-open(1). It works on all freedesktop compliant desktops.
The default programs for different mime-types are defined in /etc/mailcap and $HOME/.mailcap, indexed by file type and action (display, edit, print). The command line interface is run-mailcap. See also the manpages run-mailcap(1) and mailcap(5).
It depends what desktop environment you're using in Linux. Gnome for example has a MIME database you can use to find out what to launch for a given file.
Sahil Muthoo has given you good advice. I will just give further examples.
If xdg-open is not available you can also use "gnome-open" for GNOME and "kfmclient" for KDE.

Resources