Author Topic: What is the meaning of Slick-reg.exp '\od' ?  (Read 9451 times)

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
What is the meaning of Slick-reg.exp '\od' ?
« on: July 31, 2006, 04:46:43 PM »
Hello Slickteam,

I found a glitch in:
stdcmds.e [Revision: 1.208.2.23] - skip_word() [line 5365]:
problem:
with def_vcpp_word = 1 (although I'm using brief mode I like this setting)
and with trailing SPACEs on the curr. line
and you do next-word just before the trailing SPACEs ...
... you jump to the next line instead of the end of the line (after the trailing SPACEs)

solution:
replace:
Code: [Select]
status=search('[~\od \t]#','@re');with:
Code: [Select]
if ( ! was_end_of_line )
  status=search('[~\od \t]#|$','@re');
else
  status=search('[~\od \t]#','@re');

While doing this I've seen reg.exps like this '[~\od \t]#','@re'), but the '\od' is unkown to me (and to Slick help).
Could you please explain it ?

Thanks a lot, HS2


Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6933
  • Hero Points: 531
Re: What is the meaning of Slick-reg.exp '\od' ?
« Reply #1 on: July 31, 2006, 05:27:24 PM »
Some how this was missed.

\od     Matches any 2 byte DBCS character.  This escape is only valid in a match set ([...\od...]).  [~\od] matches any single byte character excluding end of line characters.  When used to search Unicode text, this escape does nothing.  I wrote the code :-). 

By default, SlickEdit does not convert codepage (SBCS/DBCS) source files to unicode.  This enhances the performance of tagging, file open, and file save performance.  It also allows SlickEdit to open an executable or other binary and then switch to hex editing mode without reloading or translating the data.  The only down side is that there is some extra complexity required to support DBCS and unicode data.

Hope this helps.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: What is the meaning of Slick-reg.exp '\od' ?
« Reply #2 on: July 31, 2006, 06:10:18 PM »
Thanks for your quick reply !
But it seems a bit tricky ... at least for me.

Unfortunately I'm not sure what '2 byte DBCS character' is :(
Let's try a simple example for the simple minded (as me):
using pattern [\od;]
matches ');' or ';;' but not 'b;'
Where|what is the 2 byte DBCS char. ?
Ok - I've a certain idea about 'line ending', b/c '0x0D0A' is a 2 byte 'item'. But that's not the whole truth.
It seems quite useful for some common search/replaces.
But w/o knowing, i can't make use of it.

Please try it again, HS2

BTW: Do you confirm the issue in skip_word w/ def_vcpp_word=1 ?
« Last Edit: July 31, 2006, 06:15:09 PM by hs2 »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6933
  • Hero Points: 531
Re: What is the meaning of Slick-reg.exp '\od' ?
« Reply #3 on: August 01, 2006, 02:06:20 PM »
This is a somewhat complex topic since it has to do with code page character encodings.  If you've ever had to implement DBCS support, it might make more sense.

A match set matches one and only one "character".  Don't confuse characters with bytes.  A DBCS file contains characters which are 1 or 2 bytes in length.  [\od;] will never match two single byte characters.  It matches a semicolon or a 2 byte character.  I'm guessing you don't have any files with 2 byte characters.  SlickEdit determines what could be a 2 byte character based on the active code page.  Again, in your case I'm guessing there are no 2 byte characters defined.  This would mean that [\od] matches no characters.  However, [~\od] will match every character in your file.  For SBCS (single byte character set) files, which is all you have  [~\od] is the same as [\0-\255] (slickEdit syntax).

If you want to experiment with DBCS, change your languages setting to Japanese (code page 932) and find a file with Shift-Jis in it.  The sad thing is that I actually have that code page memorized :-)

I hope I haven't confused you more.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: What is the meaning of Slick-reg.exp '\od' ?
« Reply #4 on: August 01, 2006, 03:34:58 PM »
Thanks a lot Clark for this excellent explanation. Now it's clear .. even to me ;)
HS2
« Last Edit: August 01, 2006, 03:51:21 PM by hs2 »