Use UTF-8 with BOM in Xcode - xcode

In a cross-platform workflow, I need to keep sources files in UTF-8 with BOM encoding.
When I'm editing these files in Xcode, it opens these files in UTF-8 without BOM, stripping it from file when I save it.
UTF-8 with BOM is not available in encoding drop-down list in Xcode preferences.
Is there a way to force the use of UTF-8 with BOM in Xcode?

Related

Windows: text file became binary

I am working on a QML project with Qt Creator 4.0.0 on Windows 10.
At one point I had a blue screen, and after rebooting, the file on which I was working became binary: impossible to open it on a text editor (including vim) or to see its text content.
I tried to change the file extension, to change the encoding in Sublime Text... nothing helped.
When asking for a git diff:
$ git diff qml/file.qml
Binary files a/qml/file.qml and b/qml/file.qml differ
Does anybody have any idea about how to retrieve the file?

Sass Encoding::CompatibilityError

Recently I wanted to start writing code in sass and start using compass. I installed ruby 2.0.0 and after I installed gems etc. I have this error when I try to watch files.
Encoding::CompatibilityError: incompatible character encodings: CP852 and UTF-8
Do you have any advices?
Thanks :)
I had the same issue and changed the root directory name now everything is fine.
It looks like an encoding issue. Your SASS files have different encoding from your ruby files. Try to use a decent editor that supports UTF-8 and avoid pasting stuff in your SASS files and convert any existing files to UTF-8.
If, however, you need to be using this encoding in your external files you need to tell Ruby that these files are using this encoding (as by default it assumes UTF-8). See this SO question as well Ruby, "incompatible character encodings: UTF-8 and CP852 (Encoding::CompatibilityError)"

Why is Textmate treating *.rb files as PlainText

Been using Textmate 2 for ages. Usually keep it on the nightly builds. A couple of weeks ago it started sporadically treating all my *.rb files as plaintext. And as of the latest release build - it treats all my *.rb files as Plaintext. :(
I've tried:
Turning off all the syntax highlighters, restarting TM and reinstalling them
Uninstalling TM; reinstalling the App
Using only the actual releases, instead of nightly builds
After uninstalling all language packs, it correctly asks to install coffeescript, javascript, json, etc when I open those files. However, it does not ask for a *.rb file.
I've searched the TM mailing list and found nothing similar.
*.rake, *.rbx and all the other file types listed in the Ruby Language pack are recognized as ruby.
Any ideas?
When you open a file and manually change the file type via the status bar then TextMate 2 will remember this binding (for all files using same extension) in ~/Library/Application Support/TextMate/Global.tmProperties.
There are a few options to undo a stored file type binding:
Open a *.rb file and select Ruby via the status bar.
Edit ~/Library/Application Support/TextMate/Global.tmProperties to remove anything that sets fileType for *.rb. Such entry would look like:
[ *.rb ]
fileType = text.plain
Delete ~/Library/Application Support/TextMate/Global.tmProperties.
Quit TextMate
Remove /Library/Application Support/TextMate
Remove ~/Library/Application Support/TextMate
Launch TextMate
Open a *.rb file
Profit!

Mercurial messes scandinavian characters OSX

Me and my friend set up Mercurial repository on Bitbucket for our project. He works on Windows while I use OSX. I installed Mercurial to OSX and cloned the repository only to find out that all scandinavian characters (äö) in files where interpreted wrongly. Also, folders which had those characters didn't get cloned properly.
Now, I suppose it has something to do with character encoding, which makes it somehow work on Windows, but not on OSX. I used Sourcetree as GUI for Mercurial and tried to find any character encoding settings with no results. What I should do to fix this problem? I have used GUI Mercurial on Windows before and never had problems like this.
You have usual "different encoding" problem.
OSX uses UTF8 (FIXME), Windows for Western-Europe 8bit chars (most probably) - ISO-8859-1
Before any CLI-operations in OSX you have to chcp to the same copepage, as it was on Win-side

How to create ZIP files with specific encoding

On my Linux server I have some files with accented names (test-éàïù.zip).
When I add them to a new ZIP file using 7zip command-line tool, the charset/encoding information is not saved and when opened on a Windows computer, the archive does not correctly display filenames.
I know that 7zip creates Zip V1.0 archives, not 2.0. Maybe the charset is limited to MSDos charset ?
How could I specify an encoding using 7zip or another zip tool, in order to get portable archives?
This is a superuser question, BUT...
ZIP uses a default codepage of IBM437. There is the possibility to use UTF-8, but not all zip tools and libraries support that. Some zip tools will do arbitrary code pages, even though the zip spec allows only IBM437 or UTF-8. I think WinRar is one such tool.
DotNetZip does encoding. It will do UTF-8 or an arbitrary code page. if you're writing an app, there is a .NET library. If you are running from a script, there are command line tools. Either way, DotNetZip requires .NET. You will need Mono to run it on Linux.
example for the command line:
zipit.exe Olivier.zip -cp 860 test-éàïù.txt
(to use the 860 codepage) I'm not sure that Windows Explorer correctly handles zipfiles with alternate encoding for the filenames within the zips.
See How to zip specified folders with Command Line for more info on that zipit.exe tool.
Create a ZIP file using specified code page:
7z a -mcp=<code_page> -tzip <archive_name> <file_names>...
Extract files from a ZIP file using specified code page:
7z x -mcp=<code_page> <archive_name>
I know that 7zip creates Zip V1.0 archives, not 2.0.
I couldn't work out how to use 7zip to create a zip v1.0 archive.
You can create version 1 ZIP archives using Info-Zip’s zip 1.1, which is still available (download from the FTP http://infozip.sourceforge.net/Zip.html#Downloads). You’ll need to build it from source (make sysv on a Linux system); then you’ll be able to use the newly-built zip to create old-format archives:
]# ./zip filename.zip file1 file2 file3
]# file filename.zip
]# filename.zip: Zip archive data, at least v1.0 to extract

Resources