Author
Topic: Change character encoding after a file has been opened (Read 4005 times)

I resorted to uninstalling SlickEdit, erasing the SlickEdit files in Documents, and re-apply the latest hotfix.

Still no change... UTF-8 Files without a BOM are garbled.

The only change that came of reinstalling SlickEdit is that encoding "auto unicode" was set to "auto unicode2" without me doing anything. So I guess the old value was imported from an ancient configuration and never upgraded to the new unicode2 method.

I think I should stop spamming this forum with what appears to be a support issue; SlickEdit UTF-8 with no BOM works for you and so it should for me. The mere fact that it works for you makes me a very happy person because I've for years thought that SlickEdit couldn't figure out how to handle BOM-less UTF-8 files and instead it turns out that it is some bizarre support issue I'm facing.

There's a bug in the load options encoding list. It's supposed to list UTF8, no signature. There is a workaround.

Go ahead and choose UTF8 for File>load options>encoding. Now use Macro>Set macro variable... and change +utf8s in the variable def_load_options to +futf8. The only downside to doing this is the GUI load options will be lost and can't display this setting.

My def_load_options value is (even though I've changed the encoding to UTF-8 in File>Load Options>Encoding):

+L -LF +LE -S -E +U:32000 -N +BP

If I add "+FUTF8" to this line, exit the editor, and open the document under a new name, it still doesn't work. Whether or not I use "+new -sc TempDir" on the SlickEdit command line. The manually added "+FUTF8" value does appear if I inspect def_load_options again.

The only things that work are if I use File>Reload with Encoding>UTF-8 or manually add a BOM. Then the text displays as it should.

Argh! :-) I really don't get this... We're talking about a problem that persists across operating systems, editor versions, and configurations.

i have goofed a bit here though. It turns out this work around is only needs when creating new files. Choosing Utf-8 in File>load options>encoding should recognize existing Utf-8 files with or without a signature.

Yes, but it doesn't in my end, unfortunately. I am grateful for all your help, but so far it hasn't changed anything.

I have absolutely no idea of what's going on here. I have submitted a support case - do you want me to continue in this thread or to work with Support to resolve the issue?

I rename the file every time, before I open it, to a new unique name so as to not trigger SlickEdit's built-in memory of file encodings. I have tried both with and without customized settings, even a clean install. Nothing works. And it hasn't for years, which is why I have been looking for another option recently because it is getting to be really annoying that I can't get SlickEdit to work for me.

Obviously, I'd prefer to get SlickEdit to work but I am ready to switch to another editor, if this issue cannot be resolved. I work almost full-time in UTF-8 encoded PHP files containing Danish national characters so this is a major hassle for me. Especially because the UTF-8 BOM breaks some web clients and makes the the XHTML/1.0 validator fail (the whole point of XHTML/1.0 Strict is that it can be validated sensibly).

Also, when you switch a lot between ASCII and UTF-8 files, it is a tedious hassle to have to use File>Save As to determine the encoding. This should be shown prominently on the status line or in the buffer list (I use the BRIEF emulation). I have suggested this to support long ago but nothing has happened.

Graeme reported this:

"If I turn on "line hex" in the view menu I get the incorrect version that you're getting."

So there must be some issue somewhere in there, which I am running into all the time.

A final note: I never use SlickEdit workspaces, I always open and close my files on the fly from a console window.

i have goofed a bit here though. It turns out this work around is only needs when creating new files. Choosing Utf-8 in File>load options>encoding should recognize existing Utf-8 files with or without a signature.

I just tried this:

vs.exe +FUTF8 index708.html

And it WORKED. I suppose that amounts to manually specifying the encoding. I'll change my DOSKEY alias for the time being to explicitly specify the +FUTF8 option and hopefully we can resolve this sometime.

I didn't read into the fact that you're working .html files. Now that I think about it, the solution I gave you shouldn't work for .html files because the default extension specific encoding is "Auto HTML" which overrides the global encoding setting. Go to Tools>Options>Languages>File Extension Manager and select the "html" extension. Change the encoding from "Auto HTML" to "Utf-8".

I was about to give up and have you use support (their definitely better than I am due to there customer specific experience).

You have solved a big issue for me, thanks! Even though I only used an HTML file because it illustrated my issue. I don't regularly edit HTML files so I'll leave the HTML setting as it is, but you definitely helped me get SlickEdit to work for me.

In combination with the now default +FUTF8 option (in my DOSKEY macro) in my end, I suspect we're getting to the point that it actually works for all file types: I often edit UTF-8 encoded file types that are unknown to SlickEdit and they also appear to work now (without a BOM). As far as I know, I should never run into any issues forcing the encoding to UTF-8 as I only use UTF-8 and ASCII encoded files.

Perhaps you can pull some strings and get the encoding to be displayed somewhere on the status line? Just kidding, but it would be nice :-)

I noticed this older post and wanted to note that SlickEdit does now show the encoding in the status bar, and clicking that item opens the "Save As" dialog so that you can change the encoding.Thanks for the suggestion!