Menu

Unicode support

Averell
2010-12-27
2012-07-19
  • Averell

    Averell - 2010-12-27

    It is a pity that allchars does not support Unicode. This is a strong
    limitation. It should not be so difficult to implement, since, in despair that
    allchars would ever support Unicode, I wrote a Autohotkey script which works
    in a way very similar to allchars but support full unicode. If the programers
    were interested, I can post the code which is in alpha state.

    Dysmas

     
  • Averell

    Averell - 2010-12-27

    Well, just in case someone is interested here is the code (remember this is a
    Autohotkey script) :

    ; AutoHotkey script file
    
    SetTitleMatchMode, 2
    Menu, Tray, Icon, allchars2.ico
    Menu, Tray, Tip, "Allchars V2U"
    
    #Include scripts\dictionary_v2.ahk
    
    DllCall("ole32\CoInitialize", UInt,0) 
    pdic := CreateDictionary()                 ; param = 1: Case of Key is ignored. 0 (Default): case-sensitive 
    match := ""
    
    Loop, read, allchars2U.ini
    {
        StringSplit, $def , A_loopreadline, =; , %A_Space%%A_Tab%
    
        if strLen($def1) > 0
        {           
            Add(pdic,$def1, $def2)
            StringReplace, $def3, $def1, `, , `,`, , All      ; la virgule doit être doublée dans la liste de match 
            $match .= "," . $def3                
        }
    }
    
    $hot := "~" . Get(pdic,"Hotkey")
    Hotkey, %$hot%, allchars2
    
    allchars2:
    
    Input, UserInput, V T10 L5 C, {enter}.{esc}{tab}, %$match%
    
    if ErrorLevel = Max   
        return  
    if ErrorLevel = Timeout    
        return
    if ErrorLevel = NewInput
        return 
    IfInString, ErrorLevel, EndKey:
        return
    
    ; Otherwise, a match was found.
    SetKeyDelay, -1  ; Most editors can handle the fastest speed.
    
    $result := Get(pdic,UserInput)
    ; Handle End of lines (\n)
    $eol := Chr(10)
    StringReplace, $result2, $result, \n, %$eol%, All
    
        Transform, Clipboard, Unicode, %$result2%
        $len := strLen(UserInput) + 1
        Send, {backspace %$len%}
        Send, +{INS}        ; shift + insert to paste the clipboard
    
    return
    

    Then you must have a file name allchars2U.ini which contains a line like :

    Hotkey = &

    This line define the call key (here : &). Use what you want.

    Then other lines on the model :

    code = data

    code must be a max of 5 characters.

    data can be anything, but on one line.

    end of lines are written : \n

    The file is written in utf-8.

    Comments after a ;

    Example is difficult to post here because many characters will be trashed:

    To call type & and then the code.

     
  • Averell

    Averell - 2010-12-27

    N.B. : the above script uses dictionary_v2.ahk I found this on Autohotkey
    site.

     
  • Tri

    Tri - 2011-01-09

    I can't find dictionary_v2.ahk; can you give me a link where to download it?

     
  • Averell

    Averell - 2011-01-10

    I have worked a lot on this project and the code I provided above is totally
    obsolete.

    Unicode support in AutoHotKey needs the new _L version which will not work
    with dictionary_v2.ahk.

    If you want to betatest my present working version, you can find it on the Ad-
    libros project on SourceForge.

    Go to the UniChars directory, it is there.

    I have not yet created a project for it, Ad-Libros is an old project already
    moved, so I used this folder for today. When betatesting is finished a
    UniChars project will be created.

    Best Regards

    Dysmas

     
  • Averell

    Averell - 2011-01-10

    Just an string example produced by Unichars (I am unsure if it will not finish
    in ??? because of html, but let us try. There is ciryllic, Arabic, greek in
    it.

    xxĂŠŮθЩفשּׂ\Ουκ ελάβον Πολιν\فكّٯخضڜڪڿې۞۩

     
  • Lapo Luchini

    Lapo Luchini - 2011-01-10

    I tried the betatest 0.7 (in Ad-libros) and found a few (small) bugs:

    a. it calls itself 0.6 (instead of 0.7)

    b. it doesn't parse correctly keys containing '=' (even tough there are in the
    example)

    c. the Menu (aka AppsKey) is missing from HotKey1 dropdown (but works if
    hacked to add it, except I added that after "custom" since I've seen that's
    used with direct index 12)

    d. sometimes the compose key isn't just got (doesn't even do the "usual"
    windows behaviour, though) and the following keys are just passed along

    Overall I'm very happy to have an alternative to AllChars, which often get
    stuck and must be closed-reopened.

     
  • Tri

    Tri - 2011-01-10

    I tried it a bit, it works very well. I'm trying using Ctrl as hotkey (next:
    Menu) and it never failed.

    The only thing I found at now is that Win+m is used in the script, overriding
    Windows hotkey; also, I tried to use AltGr as hotkey, but it doesn't work.
    Anyway they're only small nuisances in an excellent script.

     
  • Averell

    Averell - 2011-01-10

    Thanks for the informations.

    OK, I will fix what I can.

    On my keyboard : If I choose RAlt as Hotkey, the AltGr key works. There is no
    way in AutoHotKey to support directly AltGr.

    On my keyboard Appskey does not work because it still displays a context menu,
    that is why i suppressed it. But if it works on other systems, I will add it
    again.

    Keep in mind this is a VERY EARLY release.

    0.8 next week.

     
  • Tri

    Tri - 2011-01-10

    RAlt for AltGr works also for me, thanks.

    AppsKey gives to me the same problem, but only on one PC; tomorrow I'll check
    if the one it works on has some difference with this one (both of them runs
    English Windows XP, but I'm not sure about which SP has the other).

    By the way, I tried something like

    =

    ({space}{space} = nbsp)

    but it doesn't accept {space}{space} (not really a problem, I was only trying
    random stuff).

     
  • Tri

    Tri - 2011-01-10

    Oh, by the way: I changed #m in #h: the latter isn't a Windows hotkeys and I
    find it easier to remember (it adds a Hotstring).

     
  • Lapo Luchini

    Lapo Luchini - 2011-01-10

    The following change permits the usage of '=' as an hotkey.

    Notice that it doesn't currently support the usage of an equal in the first 4
    characters of the substituted text, tough, but that can be avoided adding a
    bit of padding spaces.

    --- unichars07.ahk.orig  2011-01-10 23:13:50.837436500 +0100
    +++ unichars07.ahk       2011-01-10 23:59:52.356386300 +0100
    @@ -69,21 +69,9 @@
         if (SubStr(A_loopreadline, 1, 1) = ";")
             continue
    
    -    $sepPos := InStr(A_loopreadline, "=")^M
    -    $colonPos := InStr(A_loopreadline, ";")^M
    -    $length := $sepPos - 1^M
    -    $dataPos := $sepPos + 1^M
    -^M
    -    $code := SubStr(A_loopreadline, 1, $length)^M
    -    $data := SubStr(A_loopreadline, $dataPos)^M
    -    $code := Trim($code)^M
    -    $data := Trim($data)^M
    -^M
    -    ;MsgBox %$code% :  %$data%  :  %A_loopreadline%^M
    -    ;StringSplit, $def , A_loopreadline, =; , %A_Space%^M
    -^M
    -    if strLen($code) > 0^M
    +    if RegExMatch(A_loopreadline, "^ *(?P<code>[^ ]{2,5}) *=(?P<data>.+)$", $) > 0^M
         {
    +        $data := Trim($data)^M
             ;if (pdic[$code])
             ;    MsgBox, WARNING : The item %$category% - %$def1% already exists
             pdic[$code]:= $data
    

    For example:

    =1=1
    =2==2
    =3===3
    =4====4
    =5=====5
    =6 = =6
    

    Gets interpreted as:

    =1 = 1
    =2= = 2
    =3== = 3
    =4=== = 4
    =5=== = =5
    =6 = =6
    
     
  • Averell

    Averell - 2011-01-11

    Some fixes in 07b (just uploaded)

    The main change is : = ; and

    if strLen($code) > 0

    {

    StringReplace, $code, $code, {equal}, % "="

    StringReplace, $code, $code, {semicolon}, % ";"

    StringReplace, $code, $code, {space}, % " "

    pdic:= $data

     
  • Tri

    Tri - 2011-01-11

    Some minor bugs:

    • If I open Configuration, make some change, then go to Help tab and then
    click "OK", UniChars is not restarted.

    • There is some problem with =; for example:

    -==≅ gives =≅ simply by pressing Compose+-.
    =-=≅ gives nothing.

    Generally speaking, if = is the first character UniChars does nothing, if it's
    the second it gives the character preceded by a = pressing the first
    character.

    • Some other troublesome code:

    Nv=↯ doesn't try discarded case (generally, if there is a capital letter and a
    small one, "Try discarded case" doesn't work).

    00=∞ gives ∞ simply by pressing Compose+0.

    Compose+CC gives C also if there is no code for it.

     
  • Tri

    Tri - 2011-01-11

    And, now #m works as Windows hotkey, but in unichars07.ahk there is still that
    code (I guess it's still the old version, while the exe is the new one).

     
  • Averell

    Averell - 2011-01-11

    Generally speaking, if = is the first character UniChars does nothing, if
    it's the second it gives the character preceded by a = pressing the first
    character

    .

    = was not supported at all in 0.7. It is now supported in 0.7b but you must
    use {equal} instead of = Your code becomes :

    -{equal}=≅
    {equal}-=≅

    Same thing for {space} instead of a space and {semicolon} instead of ;

    generally, if there is a capital letter and a small one, "Try discarded
    case" doesn't work

    True, it was designed like that, but I plan to add support for mixed case.

    00=∞ gives ∞ simply by pressing Compose+0.

    Compose+CC gives C also if there is no code for it.

    Perhaps a bug, I will check.

    (I guess it's still the old version, while the exe is the new one)

    I left the code but commented the full block with / / so it is inactive. I
    will not let down this function but I will rewrite it a little and make the
    Hotkey configurable.

    Thanks for your feedback.

     
  • Averell

    Averell - 2011-01-11

    If I open Configuration, make some change, then go to Help tab and then
    click "OK", UniChars is not restarted.

    And your changes are not saved ! Problem : This not the same OK button and
    they do totally different things. I will use a second Window instead of a tab,
    it will be more clear. But that will be for 0.9

     
  • Tri

    Tri - 2011-01-11

    Using {equal} instead of = works; sorry, I overlooked that in your post.

    As for #m: at now I changed it in #h, but having it configurable'd be great.

     
  • Averell

    Averell - 2011-01-11

    00=∞ gives ∞ simply by pressing Compose+0.

    This is a serious problem. autoHotkey converts variables which contains only
    digits in numeric and there is nothing I can do about it. Hence 00 is
    converted in 0. And if you try 001 you will find the resulting code is 1. I
    have not found a workaround and this must be considered as a limitation :
    leading 0 are not supported in purely numeric codes.

     
  • Tri

    Tri - 2011-01-12

    I noticed UniChars doesn't works in Foxit
    Reader
    : the icon turns red when
    Compose is pressed and yellow when a existing combination is typed, but the
    character(s) doesn't appear.

     
  • Averell

    Averell - 2011-01-14

    I created the UniChars project on SourceForge.

    You can find there the last version 0.8d. It seems quite stable. A lot of work
    since 0.7. Please read the doc in the part about ini files, there is important
    stuff there.

    And it is better to continue this discussion on the forum of UniChars, now.

    00=∞ gives ∞ simply by pressing Compose+0.

    fixed

    I noticed UniChars doesn't works in Foxit Reade

    Will be fixed in the next version.

     

Log in to post a comment.