Author Topic: how to force use of encoding  (Read 5878 times)

catphive

  • Community Member
  • Posts: 15
  • Hero Points: 0
how to force use of encoding
« on: September 20, 2008, 08:04:10 am »
I have a:
<?xml version="1.0" encoding="UTF-8"?>

starting out one of my documents. In fact, that document is *not* utf-8, and I *do not want it loaded* as utf-8, but as plain ascii. Basically, loading it as unicode screws up formatting on linux slickedit. I want the <?xml blah blah > at the start, because after further processing non-ascii characters may be inserted (when my document is being served by a server to a browser) but while I'm editing it, there will be none, so I don't want to load it as unicode.

I have the default encoding set to load as ascii (well, ISO-8859-1, which is close enough for my purposes), but this seems to be ignored when I have <?xml version="1.0" encoding="UTF-8"?> at the beginning of a document! I want slickedit to just be a dumb ascii text editor! How do I make this happen?

jbhurst

  • Senior Community Member
  • Posts: 406
  • Hero Points: 33
Re: how to force use of encoding
« Reply #1 on: September 21, 2008, 11:43:06 pm »
You can force the encoding to use when opening the file. I've used this before to open weird XML documents.

The option for this varies a little bit by platform because of the different File > Open dialogs. On my Linux system there is an "Encoding" drop-down right near the top of the dialog. You can use that to specify Text SBCS/DBCS.  On Windows there are two different open dialogs, and the last time I checked (SE 12) the Windows 3.1-style open dialog did not have an option to set the encoding.

Regards

John Hurst
Wellington, New Zealand

thornev

  • Community Member
  • Posts: 12
  • Hero Points: 1
Re: how to force use of encoding
« Reply #2 on: February 17, 2010, 04:16:06 pm »
I have the same problem - I want to open a file that is encoded in ASCII (8859-1).  When I select the "Western European (ISO-8859-1)" option for Encoding, I get an error:  "Code page not installed or not valid."  How do I fix or what alternatives do I have?  Thanks.  thorne

PS - I know I can use iconv on Unix to translate the file first but would rather have a SlickEdit solution.
« Last Edit: February 17, 2010, 05:20:27 pm by thornev »

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: how to force use of encoding
« Reply #3 on: February 18, 2010, 04:24:10 pm »
First, try choosing "Text, SBCS/DBCS Mode" with the open dialog. Even if it detects the file is unicode, or UTF-8 with signature, it should still force it into a SBCS code page.

If that's not what you need, try opening the file on the command line with the edit command, using +facp (platform's active code page) or +fcp850 (the 'short' codepage name for the Latin/Roman codepage series). Of course, these are the Windows/DOS flavors of these code pages, but hopefully it'll get you close to what you need.

edit +facp file.ext
edit +fcp850 file.ext
edit +fcp1252 file.ext

Let me know if that works. To verify, save the file with the "Save As" dialog, which should put the file's current code page in the drop-down on the save dialog.

thornev

  • Community Member
  • Posts: 12
  • Hero Points: 1
Re: how to force use of encoding
« Reply #4 on: February 18, 2010, 04:53:02 pm »
"Text, SCBS/DBCS Mode" didn't work - I got binary garbage.  I tried the facp options with these results:

+facp - opens as different binary garbage
+facp850 - SlickEdit error "Invalid option"
+facp1252 - SlickEdit error "Invalid option"

My SlickEdit version is 14.0.1.2.  My OS is Windows XP + SP3 and I'm accessing a file on a remote Unix system via an attached network drive (attached via NET USE).  thorne
« Last Edit: February 18, 2010, 04:55:08 pm by thornev »

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: how to force use of encoding
« Reply #5 on: February 19, 2010, 12:57:43 am »
You've got extra an extra "a" in your last 2 commands. Use +fcpNNN, and not +facpNNN.

thornev

  • Community Member
  • Posts: 12
  • Hero Points: 1
Re: how to force use of encoding
« Reply #6 on: February 19, 2010, 02:45:41 am »
Oh geez, duh.  OK, results:

+fcp850 - garbage
+fcp1252 - garbage

Just to be sure I'm doing this correctly...  My Y drive is the network drive with the ISO-8859-1 file on it.  I have a DOS command window open and I'm in that directory (Y:) and at the command line I enter "vs +fcp850 myfile.log".  "vs" is vs.exe which is in my PATH.  SlickEdit opens the file, but so far it's always unreadable symbols.  Am I missing anything?  Thanks for your help.  thorne

UPDATE - I also tried +fcp28591 where "28591" is the Windows code page code for ISO-8859-1, but that resulted in binary garbage too.
« Last Edit: February 19, 2010, 05:27:45 pm by thornev »

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: how to force use of encoding
« Reply #7 on: February 19, 2010, 11:24:31 pm »
Can you let me know what platform and version you're on, and possibly attach a sample 'garbage' file. I'd like to track this down.

thornev

  • Community Member
  • Posts: 12
  • Hero Points: 1
Re: how to force use of encoding
« Reply #8 on: February 22, 2010, 12:48:10 pm »
Platform and version number is in a previous post.  I've attached a file in question.  thorne

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: how to force use of encoding
« Reply #9 on: February 22, 2010, 10:00:32 pm »
What kind of viewer *can* display that file? It's certainly not ASCII text. There's not a single 'e' in the whole file, the most common letter in all the Latin alphabet languages. Most of the characters are above 0x74, and about 15% of the file is 0x90, which is a device control character.

thornev

  • Community Member
  • Posts: 12
  • Hero Points: 1
Re: how to force use of encoding
« Reply #10 on: February 23, 2010, 02:20:57 pm »
The file is encoded in ISO-8859-1.  I can use ICONV on it to convert it to a readable file (Unix command: iconv -f iso8859-1 -t 1047 infile > outfile).  Also, on my Unix system I can export environment variable _BPXK_AUTOCVT, setting it to "ON" (which converts to readable on the fly), and then I can run CAT on the file to view it in readable format.  

Now this is interesting... if I "ftp get" the file in binary mode (i.e. ftp get it from my Unix system to my Windows system), I can edit the file with SlickEdit and it renders correctly.  So apparently SlickEdit can interpret the file but not via Windows Explorer which uses SMB to get the file.  I wonder if this is an SMB problem.  SMB = Server Message Block (I think).  UPDATE - I think the reason I can read the file after I FTP GET it is that the file was tagged on the Unix system as being iso8859-1.  I can use Notepad to view the file and Notepad also displays it as readable which means the file is already translated by the time it got to my Windows system.

thorne
« Last Edit: February 23, 2010, 11:21:54 pm by thornev »

thornev

  • Community Member
  • Posts: 12
  • Hero Points: 1
Re: how to force use of encoding
« Reply #11 on: February 25, 2010, 02:54:40 pm »
I just found out that the filetag support in Unix is ignored by SMB by default (note that I'm talking about the SMB support in z/OS's Unix System Services) which would be the workaround for SlickEdit's inability to translate the file on the fly.  I got some help from an SMB developer so hopefully I can get SMB to honor the filetags.  

Have we given up on getting SlickEdit to translate the file on the fly?

thorne
« Last Edit: February 25, 2010, 03:00:39 pm by thornev »