Zend Studio for eclipse - Switch character encoding for all files in a project - eclipse

I'm using Zend Studio for Eclipise on Mac, and it seems to keep setting all files to have and encoding of 'Mac Roman'. This becomes problematic when I save the files, as they all need to be UTF-8.
I know how to change the encoding to UTF-8 on a file by file basis, but I was wondering if I could set this project wide?

Eclipse-Wide: Window->Preferences->Appearence->Workspace
Project-Wide: Rightclick on Project->Properties
Filewide: Rightclick on File->Properties

On my Eclipse for PHP Helios SR 2 for Mac:
Eclipse-Wide: Eclipse->Preferences->General->Workspace
The others are the same as #SkaveRat

On a Zend Studio 8.x,for Mac osx 10.5.8 I changed it like this:
Top menu chose: Edit->Set encoding->Other: UTF-8,. By default it is set Mac Roman.
And then apply.

Just remember, php does not actually support utf-8 encoded sourcefiles.
When creating strings in a utf-8 encoded file, php will just see 2 static bytes per character.
Try running the following with either utf-8 or ISO-8859-1 enconding.
strlen() will report different lengths depending on encoding.
<?php
$string = "äüö";
echo (strlen($string));
?>

Related

modify encoding for database deploy script

Is there a way to change the encoding for the deploy script generated by Sql Server Data Tools from UTF-8 to ANSI?
The problem that I have is that I have a string in a function that contains the caracter "è" and in the generated deploy script a box appears instead of this character.
EDIT: I'm using SSDT with Visual studio 2013 and 2015.
You should change encoding of all files in your project to UTF-8 and deploy script will be correct.

How to change default encoding in NetBeans 8.0 [duplicate]

This question already has answers here:
How to change file encoding in NetBeans?
(8 answers)
Closed 2 years ago.
I'm wondering if I can change default encoding in NetBeans 8.0... I searched a lot but I haven't find a way how to change the encoding in this version of NetBeans.
I have this tag in my html document:
<meta charset="utf-8">
BUT! As you can see on attached image, NetBeans notice is warning me about an encoding problem.
Internal encoding declaration "utf-8" disagrees with the actual encoding of the document ("windows-1250").
I created index.html by "new file" function in NetBeans. There is UTF-8 encoding in project properties, so I think it should be UTF-8. I really don't know where that 'windows-1250' came from!!
Where I can find some option to change default encoding or even current file encoding in NetBeans 8.0?
Solution given by Danny
Navigate to <Netbeans installation directory>/etc and open the netbeans.conf file.
Add -J-Dfile.encoding=UTF-8 at the end of the line that starts with netbeans_default_options (make sure to include the leading space).
Restart Netbeans and it should be in UTF-8
To verify go to help -> about and check System: Windows Vista version 6.0 running on x86; UTF-8; nl_NL (nb)
Answer here worked well for me on Netbeans 7.3 Stackoverflow Answer
Right click on the project name and click on properties. Sources tab -> Encoding and change it to whatever you need. In my case i needed Windows 1252 encoding.
I had the problem with a cyrillic characters (russian and ukranian letters) in netbeans 8.1 for Ubuntu 14.04. I have fixed problem like #Rex Wagenius adviced + I had to change a font of netbeans (in main menu: Tools -> Option -> Fonts&Colors -> Syntax tab -> Font changed from Courier to Serif 20). Hope this answer will be helpful for some users with the same problem.

How do I add a BOM to all UTF-8 files in a project?

Current encoding is UTF-8 and I want to add BOM to all the files
Context: Windows 8 app certification toolkit throws following error, if BOM is not added:
File C:\x\y\z.js is not properly UTF-8 encoded. Re-save the file as UTF-8 (including Byte Order Mark).
If you are using IDE like eclipse or netbeans, you can select all files and set the encoding.
Other option is open all files in text editor and change.
I know this is an old question but here is how I did it:
create a php file: addBOMtoFile.php and add the following line:
file_put_contents("some_new_file_name.js", "\xEF\xBB\xBF" . mb_convert_encoding(file_get_contents("some_file_name.js"), "UTF-8", "UTF-8"));
C:\php>php addBOMtoFile.php

Encoding - Pydev changes character automatically

I am encoding every py script in my project to utf-8, as we are definitely migrating our application from Jython 2.2.1 to Jython 2.5.2. For that reason, I have added a 'magic comment' at the first line of every py file (#encoding=utf-8) and I have started testing whether everything is OK by debugging the application in Eclipse.
The problem appears in a script that contains the string straße, because it is automatically converted to straße.
My doubt is if this change is caused by Pydev or it happens because utf-8 doesn't cover this kind of characters.
What can I do to automatically avoid this issue with other 'strange' strings I haven't detected yet?
Are you sure your .py files use UTF-8 encoding? Try to open it with WebBrowser (as text) and check various encodings. While you see straße if seems that ß is encoded by two bytes (most probably UTF-8) but ensure it is really UTF-8.
Also check in Eclipse settings on Project/Properties. There is Resource panel with "Text file encoding" setting (I use Eclipse only for Java projects and do not know if Pydev uses this setting).
Try such code with PyDev and check if result file contains UTF-8 text:
# -*- coding: utf8 -*-
import codecs
f = codecs.open('strasse.txt', 'wb', 'UTF-8')
f.write('straße'.decode('UTF-8'))
f.close()
My guess is that you had a different encoding at that file (say cp1252, which is the default windows encoding) and when you put utf-8 it became garbled (so, it wasn't really PyDev who garbled it, but the fact that it was previously in another encoding).
While you're at it, also make sure you also set the default encoding for Eclipse to utf-8 (which is usually the default platform encoding) -- you can do this at preferences > general > workspace.
As a note, I believe the most common way of putting that comment is #coding: utf-8, followed by #-*- coding: utf-8 -*- (i.e.: not #encoding:utf-8) -- although all those formats work (see pep: https://www.python.org/dev/peps/pep-0263/)

Change file encoding without information losses in intellij idea

Is it possible to change file's encoding from UTF-8 to windows1251 without cyrillic information lost. Because when I explicitely change the encoding, all cyrillic symbols become unreadable?
UPDATE: new IDE versions can convert encodings:
http://blogs.jetbrains.com/idea/2013/03/use-the-utf-8-luke-file-encodings-in-intellij-idea/
The problem is that IntelliJ IDEA doesn't actually convert your file encoding from UTF-8 to windows-1251, what happens is that you tell IntelliJ IDEA to treat UTF-8 file as being encoded in windows-1251, so you will see garbage in the editor. The actual file on disk remains in UTF-8.
You have to use some external tool to perform the conversion, such as iconv:
iconv.exe -f utf-8 -t windows-1251 <input file> > <output file>
Newer versions of IntelliJ will ask if you would like to "Reload" or "Convert" the file to the new encoding.
I had a file that was displayed using UTF-8 but was actually written in x-macRoman. I selected x-macRoman and chose "Reload" so that the encoding would be used to interpret the file, I then chose UTF-8 and selected "Convert". Now my file is properly encoded as UTF-8
Tested With: version 12.1.3