Unable to create a file with foreign language characters - eclipse

I get the following error, when trying to save a properties file (containing name/value pairs) with foreign language characters. How do I set the encoding?
Save could not be completed. Some characters cannot be mapped using
"Cp1252" character encoding. Either change the encoding or remove the
characters which are not supported by the "Cp1252" character encoding.

I presume its eclipse:
Go to Windows Menu –> Preferences –> General (expand it) –> Workspace (click on it)
Look for a box “Text File Encoding”. Default will be “Cp1252″.
Change radio to select other and select “UTF-8″ from combo box.

That looks like Eclipse.
Cut the whole contents of the file into the clipboard.
Save the (now empty) properties file.
Change the encoding settings of the file (Alt+Enter) to be UTF-8 or whatever you need.
Paste the clipboard into the editor.
Save the editor.

Assuming it is in Eclipse, easiest way is to choose Save as UTF-8 option present in the error dialog box.
The other answers work well too.

Best possible solution for this , which I always do .Is to go the respective file in your workspace open it in notepad++ and make the desired changes. Once done , save the file.
Your eclipse will ask you to update the code with the changes . Click yes.
And you are all good to go now.

Fist copy the file and delete that file and then cleat your code in the eclipse after
create file with same content and rewrite the code it will resolve.

Related

CSS Files Opening Up as Plain Text in VS Code

For some reason, whenever I create a new file and give it a css extension, the language mode is set to plain text. That is not the usual behavior and I don't know why it is acting that way.
Does anyone know how to fix that?
Thanks.
Click to the language at the right bottom bar of VSCode
Select Configure File Association for '.css'
Find CSS and select it.
You could run into problem cannot finding CSS in the last step I mentioned above, then here might be the fix for it btw:
Press Ctrl + , to open the Settings window.
Click Open Settings (JSON)
Find a line where there is
"files.associations": {
"*.css": "Plain Text"
}
and delete it, make sure the json file still in a correct format after deleting (no missing or extra comma ,).

Change VSCode Default Language for new files?

Is there a way in Visual Studio Code to change the default language that is used for new files?
By default if you open a new file, it's set for "Plain Text", I want this to be "HTML" instead.
I am often copy pasting HTML into VSC, editing a bit, then copying it back to a CMS I am using (the CMS editor is horrible). I don't want to save the code on my computer at all, just edit it a bit with HTML syntax highlighting, but I want that to be the default.
You can now set the default language at either the user or workspace settings level using files.defaultLanguage:
"files.defaultLanguage": "html"
This can be done as a one off by changing the language mode:
F1 to launch command palette
Type lang, enter
Type html, enter
Now you can do this change. Check out
"files.defaultLanguage" in settings.
With v1.42 you can either set
"files.defaultLanguage": "${activeEditorLanguage}"
and when you open a new untitled file with an html file as the last active file, the new file will automatically be assigned a languageMode of HTML.
Alternatively, pasting any html code into a new untitled file from a vscode editor will automatically be detected and the languageMode set to HTML. Unless you have specifically set
"files.defaultLanguage": "plaintext"
then the languageMode will not be automatically detected as of v1.43.
Also see https://stackoverflow.com/a/68596936/836330 for a preview language detection feature in vscode 1.59.
A slightly quicker way to accomplish what Daniel had answered:
Press Ctrl+K, then M
Type html, then press Enter
I had a similar issue with VS Code. I wanted to default to Python when opening new files.
Solution: Click on File > Preferences > Settings. In the search area, Type: "files.defaultLanguage". Then fill in the language of your choice.
Perhaps you could create a scratch file with the .html extension? Open that when you need to do some copy/paste editing.

How to change encoding of all files at once with Jetbrains IDE like WebStorm

For some unknown reason, the encoding of my files has changed without me noticing for a while.
It was UTF-8 and now is windows-1252. I have reset the project encoding from Settings->File encoding but I can't detect which files are badly encoded and can't figure out how to reencode all files within the project at once.
I have a strong feeling that the problem appeared with WebStorm 10 first released version, but I may be wrong. (I think it's because it set by default the project encoding setting to windows-1252)
Close every project you have opened by clicking File > Close Project.
Once they are all closed, the startup window will show up (The window with the latest opened projects with the options to open new project, etc..) In that window, at the bottom right corner you have settings.
In Settings > Editor > File Encodings.You can set up all the File Encoding options to UTF-8, it will be added to the new projects from now on.
If you want it for old projects, do the same steps, but access the settings once you have the project open.
I hope this help!
To convert the file encoding, you have to use some external tool to perform the conversion, such as iconv:
iconv -f windows-1252 -t utf-8 <input file> > <output file>
You can change your code's character set in WebStorm foot bar
Open code file
You can see foot bar ( This menu is in right down. )
Click character set select bar
change your code encoding
change and save
If you have encoding defined in your files e.g. like this <meta charset="windows-1252">
you can you use Idea's Replace in Path... functionality and modify multiple files at once.
Even you don't have that definition, you may be able to add it to your files using the same search and replace functionality. I had to convert massive amount of ISO-8859-1 encoded file to UTF-8 and this solution worked fine.

How do I see the current encoding of a file in Sublime Text?

How do I see the current encoding of a file in Sublime Text?
This seems like a pretty simple thing to do but searching has not yielded much. Any pointers would be appreciated!
Since this thread is a popular result in google search, here is the way to do it for sublime text 3 build 3059+:
in user preferences, add the line:
"show_encoding": true
Another option in case you don't wanna use a plugin:
Ctrl+`
or
View -> Show Console
type on the console the following command:
view.encoding()
In case you want to something more intrusive, there's a option to create an shortcut that executes the following command:
sublime.message_dialog(view.encoding())
With the EncodingHelper plugin you can view the encoding of the file on the status bar. Also you can convert the encoding of the file and extended another functionalities.
For my part, and without any plug-in, simply saving the file either from the File menu or with keyboards shortcuts
CTRL + S (Windows, Linux) or CMD + S (Mac OS)
briefly displays the current encoding - between parentheses - in the status bar, at the bottom of the editor's window. This suggestion works in Sublime Text 2 and 3.
Note that the displayed encoding to the right in the status bar of Sublime Text 3, may display the wrong encoding of the file if you have attempted to save the file with an encoding that can't represent all the characters in your file.
In this case you would have seen an informational dialog and Sublime telling you it's falling back to UTF-8. This may not be the case, so be careful.
ShowEncoding is another simple plugin that shows you the encoding in the status bar. That's all it does, to convert between encodings use the built-in "Save with Encoding" and "Reopen with Encoding" commands.
plugin ConverToUTF8 also has the functionality.

iphone sdk Localizable.strings files displaying incorrecting in xcode 4.1 after upgrading

After upgrading to iphone xcode 4.1 build 4B110F all of my localizable.strings files are showing up as gibberish in the xcode editor. I created these files using UTF-16. I can not find a way to tell the editor that they are UTF-16. I am able to view the Localizable.strings files by viewing as a property list, but if I view them as Source Code, I see gibberish. I like to translate the entire localization.strings file and paste it into the editor. I don't want to have to cut and paste one line at a time in the property editor. There should be some way to tell xcode to show the file as UTF-16. Does anyone have any ideas?
I tried removing the files and re-adding them. I used to get prompted for the UTF type, but it does not do this any more.
You can find the text encoding setting for a file in the Utility area of Xcode 4.1. The utility area is the right-handside lateral area.
In the utility area, look for and select the first pane, named "File Inspector".
There, you will find the text encoding in the "Text Settings" block. Expand if necessary using the triangle.
I had this same problem. I was able to work around it (without much actual investigation) by simply opening the previous string files in TextWrangler, then copy from TextWrangler and paste into XCode4's view of the string file. Things seem to be working fine as a result.
To fix XCode 4.1 UTF-16 encoding issues:
1: Open the file you want to change
2: Put your cursor into the file, which will give the editor focus (VERY IMPORTANT).
3: Proceed to look under the Utilities Pane (very far right) for Text Settings and use the Text Encoding drop down to select UTF-16 or whatever other encoding you want.
If you forget step 2, and only highlight the file in the Project Navigator, you will not see encoding options.