Author Topic: Knowing CURRENT ENCODING - impossible ???  (Read 5846 times)

tod

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Knowing CURRENT ENCODING - impossible ???
« on: June 20, 2014, 05:55:55 AM »
Is there a way to know the encoding of current document ???
(which encoding is slickedit using on this document?)

See the following link :
http://community.slickedit.com/index.php?topic=8989.0

Seems it is really impossible.
If it is really impossible, it may be the greatest fault in Slickedit.

Thank you.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Knowing CURRENT ENCODING - impossible ???
« Reply #1 on: June 20, 2014, 06:30:03 AM »
It's not impossible. You could use e.g. this helper macro (using _EncodingToName just strips the leading '+f')
You can simply invoke it on commandline or bind it to a key or add it to the context menu...
Alternatively dry-run 'File>Save As'. The dialog also displays the current encoding.
HS2

tod

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Knowing CURRENT ENCODING - impossible ???
« Reply #2 on: June 20, 2014, 07:28:55 AM »
Thank you. 'Save as' method really worked. But the other method looks complicated and out of reach.
Can you teach me more ? I am not a professional programmer but I have to use this software...
Looks like I have to copy following (between == and ==) texts or its variant, and then paste it to some blank space in a slickedit and press enter key...
==============================
_command void show_encoding() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_EDITORCTL)
{
   message(_EncodingToOption(p_encoding));
}
==========================
1) Could you amend (if needed) above codes?
2) Where should I paste the code in slickedit and press enter key ?
At least I know that left bottom blank is for commandline. I copied that codes with ctrl+C, and paste it in commnadline blank and pressed enter, but the commnadline says 'Invalid number'.
Thank you!

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Knowing CURRENT ENCODING - impossible ???
« Reply #3 on: June 20, 2014, 08:16:13 AM »
Ok - this is a Slick-C macro. You can program SlickEdit itself using Slick-C macro code and in fact quite a lot of SlickEdit is programmed in Slick-C.
To add this tiny macro do the following steps:
- use 'Macro>Record Macro' immediately followed by 'Macro>Stop Recording Macro'
- now a dialog appears asking you what to do with the recorded (dummy) macro
- enter e.g. 'show-encoding' as macro name and also select 'Allow in read only mode' checkbox and click 'Save'
- now the macro module 'vusrmacs.e' containing user defined, recorded macros should be opened similar to this:
Code: [Select]
#include "slick.sh"

_command show_encoding() name_info(','VSARG2_MACRO|VSARG2_MARK|VSARG2_READ_ONLY|VSARG2_REQUIRES_MDI_EDITORCTL)
{
   _macro('R',1);
}

- replace the line
Code: [Select]
_macro('R',1);with
Code: [Select]
message(_EncodingToOption(p_encoding));
- use 'Macro>Load Module to compile/add the new 'show-encoding' command to your SlickEdit configuration

This new command can be bound to a key etc. or simply can be invoked on SlickEdit commandline.
Hit ESCape or just click on it to activate and enter e.g. 'show-encoding' and hit 'ENTER' to run it.

Good luck, HS2
« Last Edit: June 20, 2014, 08:21:41 AM by hs2 »

tod

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Re: Knowing CURRENT ENCODING - impossible ???
« Reply #4 on: June 21, 2014, 01:37:48 AM »
Thank you!! I understood it. And it really works.
It shows me a serial instead of full name. (like +fcp-737, instead of greek IBM pc (windows 737)).
But I am fully satisfied!

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Knowing CURRENT ENCODING - impossible ???
« Reply #5 on: June 21, 2014, 08:49:16 AM »
Great ! And yes - _EncodingToOption or alternatively _EncodingToName provide the SE internally used (short) form of the encoding file option.
_EncodingToName just omits the leading '+f' i.e. returns 'cp-737' instead of +fcp-737' for 'code page 737'.

You can modify your user macros with 'Macro>List Macros', select e.g. 'show-encoding' and click 'Edit'.
When done you need to use 'Macro>Load Module' to re-compile it.
HS2

Bamsen

  • Community Member
  • Posts: 66
  • Hero Points: 8
Re: Knowing CURRENT ENCODING - impossible ???
« Reply #6 on: June 21, 2014, 11:55:20 AM »
Is it also possible to change the encoding without reloading the file?

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: Knowing CURRENT ENCODING - impossible ???
« Reply #7 on: June 21, 2014, 01:05:35 PM »
You can also use 'File>Save As...' resp. the '[gui-]save-as' command to convert a file to a diff. encoding.
HS2
« Last Edit: June 21, 2014, 01:07:09 PM by hs2 »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6826
  • Hero Points: 526
Re: Knowing CURRENT ENCODING - impossible ???
« Reply #8 on: June 22, 2014, 11:18:33 PM »
Is it also possible to change the encoding without reloading the file?

The File drop-down menu has a "Reload with Encoding..." option which may be what you're looking for. It's easier than closing and reopening the file.

Bamsen

  • Community Member
  • Posts: 66
  • Hero Points: 8
Re: Knowing CURRENT ENCODING - impossible ???
« Reply #9 on: June 23, 2014, 01:01:06 PM »
This sounds good.
Can this reload be done with a macro that specifies the new encoding?

Matthew

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 990
  • Hero Points: 44
Re: Knowing CURRENT ENCODING - impossible ???
« Reply #10 on: June 23, 2014, 01:40:54 PM »
All the reload_with_encoding macro does is fill out the +F (or +fcp) command line option that is passed to the e() command (shorthand for edit()) .

If you type help e on the SlickEdit command line, it'll bring up the API documentation that covers the different +F options. It's pretty easy from there to create your own macro that calls the edit command with the encoding that you want.