Loading ...
Sorry, an error occurred while loading the content.

Re: alphanumeric character transcoding, by ones and pairs

Expand Messages
  • flo.gehrke
    ... Richard, Two more ideas: 1. If in LIST.TXT the » is OK for you as a separator then we don t have to replace the pipe in that list any more but only the
    Message 1 of 19 , Jun 21, 2013
    • 0 Attachment
      --- In ntb-clips@yahoogroups.com, "rickah" <richolland@...> wrote:
      >
      > Yes, you are again correct. I did make those changes but failed
      > to note them all here. This is my LIST.TXT as it stands now
      > --
      > LIST.TXT
      > a»g
      > A»h
      > (...)

      Richard,

      Two more ideas:

      1. If in LIST.TXT the '»' is OK for you as a separator then we don't have to replace the pipe in that list any more but only the CRNL.

      2. Your new LIST.TXT is containing...

      .»$

      Please note that the dot is a RegEx metacharacter which means 'any character except NL'. As a literal character it must be escaped with '\.' on the left:

      \.»$

      If you like we could omit the escaping in the list and insert two command lines which will automatically check any search character and add the backslash if needed -- see below.

      If you prefer this solution then remove all backslashs on the left in LIST.TXT.

      Regarding these ideas, now the latest version could be...


      ^!SetHintInfo Working...
      ^!SetScreenUpdate Off
      ^!SetClipboard ^$GetFileText(^$GetDocumentPath$LIST.TXT)$
      ^!SetClipboard ^$StrReplace(\R;»;^$GetClipboard$;RA)$
      ^!SetListDelimiter »
      ^!SetArray %Char%=^$GetClipboard$
      ^!Set %i%=0

      :Loop
      ^!Inc %i%
      ^!If ^%i% > ^%Char0% Out
      ^!Set %Search%=^%Char^%i%%
      ; New: Check for metacharacters
      ; --- Long line start---
      ^!IfMatch "(\.|\[|\(|\)|\^|\$|\*|\+|\?|\\|{|\|)" "^%Search%" Next Else Skip
      ; --- Long line end ---
      ^!Set %Search%=\^%Search%
      ^!Inc %i%
      ^!Set %RepWith%=^%Char^%i%%
      ^!Replace "(?<!\|)^%Search%" >> "|^%RepWith%" WARS
      ^!Goto Loop

      :Out
      ^!Replace "|" >> "" WATS
      ^!Info Finished!

      Regards,
      Flo
    • rickah
      That does simplify things. I don t have to guess which characters need to be escaped. Eventually, nearly all keyboard characters may need to be added to the
      Message 2 of 19 , Jun 22, 2013
      • 0 Attachment
        That does simplify things. I don't have to guess which characters need to be escaped. Eventually, nearly all keyboard characters may need to be added to the list.


        --- In ntb-clips@yahoogroups.com, "flo.gehrke" <flo.gehrke@...> wrote:
        > Richard,
        >
        > Two more ideas:
        >
        > > >
        > If you like we could omit the escaping in the list and insert two command lines which will automatically check any search character and add the backslash if needed -- see below.
        >
        > If you prefer this solution then remove all backslassh on the left in LIST.TXT.
        >
        > Regarding these ideas, now the latest version could be...
        >

        ^!IfMatch "(\.|\[|\(|\)|\^|\$|\*|\+|\?|\\|{|\|)" "^%Search%" Next Else Skip
        ^!Set %Search%=\^%Search%

        I've put the list.txt in the notepad.exe folder so I don't lose track of it.

        Would you be able to help implement the suggestion of Ian to use a clip list instead? I'm thinking it would make things much easier to share. (The clip H="_list" matches the LIST.TXT.)

        > ^!SetListDelimiter ^p
        > ^!SetArray %Charpair%=^$GetClipText("list")$
        > ^!Set %i%=0

        > :Loop
        > ^!Inc %i%
        > ^!If ^%i% > ^%Charpair0% Out
        > ^!SetListDelimiter ^T
        > ^!SetArray %pair%=^%Charpair^%i%%
        > ^!Set %Search%=^%pair1%
        > ;^!Inc %i%
        > ^!Set %ReplaceWith%=^%pair2%
        > ^!Replace "(?<!\|)^%Search%" >> "|^%ReplaceWith%" WARS
        > ^!Goto Loop

        One very minor error when setting list items; with "M|&Sl", the letter M is replaced by the complex character "&Sl". I found that this entry must follow "S|p" or "&Sl" beocmes "&pl".

        This reminds me that I'll eventually be working with character codes such as: ၁ and "\u1063\u103A". Do you foresee much difficulty?

        Rick
      • rickah
        I m going to end up with three or four conversion lists, so having them as separate text files is the better idea. Thanks again, Flo. R. Holland.
        Message 3 of 19 , Jun 28, 2013
        • 0 Attachment
          I'm going to end up with three or four conversion lists, so having them as separate text files is the better idea.

          Thanks again, Flo.
          R. Holland.
        Your message has been successfully submitted and would be delivered to recipients shortly.