Jump to content

Convert Text of a .log


OliverA
 Share

Recommended Posts

Hi guys, i have a strange situation and i can resolve only with a script

I have a log of a webform of a mine friend ( not do it by me ) but this log have problem with uppercase and shift+Char.

Example:

[cod_d]h[cod_u]i autoit forum[cod_d]1[cod_u]

The result will be:

Hi autoit forum!

the h --> H

The 1 --> !

How i can substitute the lowercase with the uppercase based on [code_d]text[code_u] and convert the SHIFT + Char?

Thanks for any help

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Link to comment
Share on other sites

  • Moderators

OliverA,

Perhaps something along these lines: ;)

#include <Array.au3>

$sText = "[cod_d]h[cod_u]i autoit forum[cod_d]1[cod_u]"
; Get all instances of shift
$aAll_Instances = StringRegExp($sText, "(?U)(\[cod_d].\[cod_u\])", 3)
; Get a unique set
$aUnique_Instances = _ArrayUnique($aAll_Instances)
; Check each instance
For $i = 1 To $aUnique_Instances[0]
    ; Get unshifted ASCII
    $iAscii_Org = Asc(StringMid($aUnique_Instances[$i], 8, 1))
    ; Depending on character - convert to shifted ASCII
    Switch $iAscii_Org
        Case 97 To 122
            $iAscii_New = $iAscii_Org - 32
        Case 48 To 57
            $iAscii_New = $iAscii_Org - 16
    EndSwitch
    ; Relace all instances
    $sText = StringReplace($sText, $aUnique_Instances[$i], Chr($iAscii_New))
Next
; And show the result
ConsoleWrite($sText & @CRLF)

The _ArrayUnique is not essential, but does cut down on the number of passes through the loop if there are several instances of the same letter being shifted in the text. ;)

I hope it is useful. :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

@M23 isn't -16 making it go wrong

I mean use 2 instead of 1 you get a " instead of a @

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

Hi Melba23, thanks for your help

In the [cod_d]h[cod_u] can be more then one char, like:

[cod_d]love[cod_u] autoit [cod_d]111[cod_u]

Will be:

LOVE autoit !!!

Seems your code not work with multiple character

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Link to comment
Share on other sites

I guess this way should do the work

#include <BackRef.au3>

Local $String = "[cod_d]love[cod_u] autoit forum[cod_d]1[cod_u]"

Local $Replaced

While 1
$Replaced = RegExBackRef($String, '(.*?)(\[cod_d\].*?\[cod_u\])(.*)', '\2', "ReplaceFunc")
If $Replaced = -1 Or @error Then ExitLoop
$String = $Replaced
WEnd

MsgBox(64, 'Test', $String)

Func ReplaceFunc($sMatch)
ConsoleWrite("Matched Character:" & $sMatch & @CR)
;Strip [cod_d]
$sMatch = StringRegExpReplace($sMatch, "(?i:\[cod_[ud]\])", "")
Return GetShiftChar($sMatch)
EndFunc ;==>ReplaceFunc

Func GetShiftChar($sString)
Local $hGUI = GUICreate('', -400, -400)
Local $iEdit = GUICtrlCreateEdit('', 10, 10)
GUISetState()
ControlSend($hGUI, '', $iEdit, "{SHIFTDOWN}" & $sString & "{SHIFTUP}")
Local $sRead = GUICtrlRead($iEdit)
GUIDelete()
Return $sRead
EndFunc ;==>GetShiftChar

Hope this helps

Regards :)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

  • Moderators

PhoenixXL,

It obviously depends on the keyboard - that works for my UK one. ;)

OliverA,

Then why on earth did you not explain straightaway that there could be multiple characters? I am getting really pissed-off with people who ask a question and then complain that a posted solution does not meet their requirements only because they did not properly specify them in the first place. :mad2:

It was sort of implicit in the post. :>

Let me see what I can do to meet this new demand. :)

M23

Edited by Melba23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

  • Moderators

OliverA,

This should do the trick: ;)

#include <Array.au3>

$sText = "[cod_d]hell[cod_u]O autoit forum[cod_d]1[cod_u]"

$aAll_Instances = StringRegExp($sText, "(?U)(\[cod_d].+\[cod_u\])", 3)

$aUnique_Instances = _ArrayUnique($aAll_Instances)

For $i = 1 To $aUnique_Instances[0]
    ; To hold shifted chars
    $sNew_Chars = ""
    ; Extract and split the existing chars
    $sChars = StringReplace(StringReplace($aUnique_Instances[$i], "[cod_d]", ""), "[cod_u]", "")
    $aChars = StringSplit($sChars, "")
    ; Convert to shifted
    For $j = 1 To $aChars[0]
        $iAscii_Org = Asc($aChars[$j])
        Switch $iAscii_Org
            Case 97 To 122
                $iAscii_New = $iAscii_Org - 32
            Case 48 To 57
                $iAscii_New = $iAscii_Org - 16
        EndSwitch
        ; Add to new string
        $sNew_Chars &= Chr($iAscii_New)
    Next
    ; Replace string
    $sText = StringReplace($sText, $aUnique_Instances[$i], $sNew_Chars)

Next

ConsoleWrite($sText & @CRLF)

Just promise me that you will explain the problem fully next time. OK? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Melba, i have write:

based on [code_d]text[code_u]

Next time i'll be more clear, i'm testing your script

EDIT I have some problem ;)

1 = ! Correct

2 = " Correct

3 = # NOT CORRECT --> This is the right £

4 = $ Correct

5 = % Correct

6 = & Correct

7 = ' NOT CORRECT --> This is the right /

8 = ( Correct

9 = ) Correct

0 = Nothing NOT CORRECT --> This is the right =

And if add a different char like

[code_d]+[code_u]

Give me error and not work:

$sNew_Chars &= Chr($iAscii_New)
$sNew_Chars &= Chr(^ ERROR

SHIFT + "+" = *

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Link to comment
Share on other sites

  • Moderators

OliverA,

You are quite right - and I apologise. :>

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

You don't need to apologize, you are help me so it's not a problem for me testing your script ;)

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Link to comment
Share on other sites

Here a way but might be silly:

#include <WindowsConstants.au3>
$sString = "[cod_d]1a-[cod_u]h autoit forum[cod_d]2b[cod_u]"

Global $sKey, $hGUI, $iCtrl

$sResult = Convert($sString)
ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $sResult = ' & $sResult & @crlf) ;### Debug Console

Exit

Func Convert($sString)
    Local $aTokens = StringRegExp($sString, "(?iU)(\[cod_d\].+\[cod_u\])", 3)
    If @error Then Return SetError(1, 0, "")
    $hGUI = GUICreate("", 0, 0)
    $iCtrl = GUICtrlCreateInput("", 0, 0, 1, 1)
    ControlFocus($hGUI, "", $iCtrl)
    GUISetState(@SW_HIDE)
    Local $sChar, $sNew = $sString, $aChar, $i, $j
    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND_GetKey")
    Sleep(20)
    For $i = 0 To UBound($aTokens) - 1
        $sChar = StringRegExpReplace($aTokens[$i], "(?i)\[cod_d\](.*)\[cod_u\]", "$1")
        $aChar = StringSplit($sChar, "", 2)
        For $j = 0 To UBound($aChar) - 1
            ControlSend($hGUI, "", $iCtrl, "+" & $aChar[$j])
        Next
        $sNew = StringReplace($sNew, "[cod_d]" & $sChar & "[cod_u]", $sKey)
        GUICtrlSetData($iCtrl, "")
    Next
    GUIRegisterMsg($WM_COMMAND, "")
    GUIDelete()
    Return $sNew
EndFunc

Func WM_COMMAND_GetKey($hWnd, $Msg, $wParam, $lParam)
    Switch BitAND($wParam, 0x0000FFFF)
        Case $iCtrl
            $sKey = GUICtrlRead($iCtrl)
    EndSwitch
    Return "GUI_RUNDEFMSG"
EndFunc

The key conversation depends on your local language keyboard setting!

Br,

UEZ

Edited by UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Hi UEZ,

Not work for multiple char, but all the rest seems ok :D

I can use this example by you or Melba for load-save from a txt, right?

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Link to comment
Share on other sites

  • Moderators

OliverA,

As it seems there are so many possibilites for the shifted characters depending on the keyboard layout, I suggest that you create a 2D array to hold the unshifted and shifted charactes that are correct for your keyboard and then convert them directly. Something like this should work: :)

#include <Array.au3>

; Declare an array holding all the unshifted and shifted charactera for your particular keyboard
Global $aShifted_Array[2][2] = [["a", "A"], ["b", "B"]]

$sText = "[cod_d]a[cod_u]h autoit forum[cod_d]b[cod_u]"

$aAll_Instances = StringRegExp($sText, "(?U)(\[cod_d].+\[cod_u\])", 3)

$aUnique_Instances = _ArrayUnique($aAll_Instances)

For $i = 1 To $aUnique_Instances[0]
    ; To hold shifted chars
    $sNew_Chars = ""
    ; Extract and split the existing chars
    $sChars = StringReplace(StringReplace($aUnique_Instances[$i], "[cod_d]", ""), "[cod_u]", "")
    $aChars = StringSplit($sChars, "")
    ; Convert to shifted
    For $j = 1 To $aChars[0]
        $sNew_Chars &= $aShifted_Array[_ArraySearch($aShifted_Array, $aChars[$j])][1]
    Next    ; Replace string
    $sText = StringReplace($sText, $aUnique_Instances[$i], $sNew_Chars)

Next

ConsoleWrite($sText & @CRLF)

Better? :)

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

mmm not work lol

$sText = "[cod_d]1a[cod_u]h autoit forum[cod_d]2b[cod_u]"

: ==> Array variable subscript badly formatted.:
$sNew_Chars &= $aShifted_Array[_ArraySearch($aShifted_Array, $aChars[$j])][1]
$sNew_Chars &= $aShifted_Array[^ ERROR
->16:29:28 AutoIT3.exe ended.rc:1
>Exit code: 1 Time: 1.985

EDIT: I need to declare the char, yes work sorry.

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Link to comment
Share on other sites

Hi UEZ,

Not work for multiple char, but all the rest seems ok :D

I can use this example by you or Melba for load-save from a txt, right?

Code updated - try again.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Didn't my solution work ??

No feedback :(

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

Phoneix, sorry if i don't have give you my feedback, not work for other char like:

Local $String = "[cod_d]love[cod_u] autoit forum[cod_d]+[cod_u]"

UEZ, i'm testing your update script

EDIT: Same problem as Phoneix, work fine with A-Z and 1-9, but not work with <,.-òàùè+'ì

The problem is this line:

$sChar = StringRegExpReplace($aTokens[$i], "\[cod_d\](\w+)\[cod_u\]", "$1")

w = Match any "word" character: a-z, A-Z, 0-9 or underscore (_)

W = Match any non-word character

If i use S = Match any non-whitespace character it convert both, but i don't know if it is right.

Edited by OliverA

I'M QUIT FROM THIS FORUM!

It was fun until it lasted, hope on my future way i can't find people that offend without any reason ( i was called lazy and parasitic, and everyone agreed...United we stand, divided we fall ) just for fun because don't have anything to do in the life, without knowing anything about the person who write, noone forced to post, noone forced to help.

From the top of the from their very great superiority they not go down to my level, that people can not spread the knowledge but you have to learn by yourself.

In what way? It's easy...just search on google

For that people, wish you the best way,

Oliver Astone

Link to comment
Share on other sites

Try again. Seems that òàùè is not supported by Controlsend() function. German üäö is supported.

Br,

UEZ

Please don't send me any personal message and ask for support! I will not reply!

Selection of finest graphical examples at Codepen.io

The own fart smells best!
Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!
¯\_(ツ)_/¯  ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ

Link to comment
Share on other sites

Phoneix, sorry if i don't have give you my feedback, not work for other char like:

I guess pressing shift + "+" will give you "+" only rite :huh:

If you are worried about blank chars try this

#include <BackRef.au3>

Local $String = "[cod_d]love[cod_u] autoit forum[cod_d]+[cod_u]"

Local $Replaced

While 1
$Replaced = RegExBackRef($String, '(.*?)(\[cod_d\].*?\[cod_u\])(.*)', '\2', "ReplaceFunc")
If $Replaced = -1 Or @error Then ExitLoop
$String = $Replaced
WEnd

MsgBox(64, 'Test', $String)

Func ReplaceFunc($sMatch)
ConsoleWrite("Matched Character:" & $sMatch & @CR)
;Strip [cod_d]
$sMatch = StringRegExpReplace($sMatch, "(?i:\[cod_[ud]\])", "")
Return GetShiftChar($sMatch)
EndFunc ;==>ReplaceFunc

Func GetShiftChar($sString)
Local $hGUI = GUICreate('', -400, -400)
Local $iEdit = GUICtrlCreateEdit('', 10, 10)
GUISetState()
ControlSend($hGUI, '', $iEdit, "{SHIFTDOWN}" & $sString & "{SHIFTUP}")
Local $sRead = GUICtrlRead($iEdit)
GUIDelete()
If $sRead Then Return $sRead
Return $sString
EndFunc ;==>GetShiftChar

òàùè+'ì

How do you want to convert them :huh:.

Do you just want Diacritics

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

This would help you get Capital Unichar(Diacritics)

#include <BackRef.au3>

Local $String = "[cod_d]àæ 2pxl[cod_u] does this help [cod_d]> +[cod_u]"

MsgBox(64, 'Test', GlobalBackRef($String, '(.*?)(\[cod_d\].*?\[cod_u\])(.*)', "ReplaceChar_UniChar"))

Func ReplaceChar_UniChar($sMatch)
ConsoleWrite("Char Match:" & $sMatch & @CR)
;Strip [cod_d] [cod_u]
$sMatch = StringRegExpReplace($sMatch, "(?i:\[cod_[ud]\])", "")
;get the shift char
$sShif_Chars = GetShiftChar($sMatch)
;get the caps uni char
$sShif_UniChars = GlobalBackRef($sShif_Chars, '(.*?)([\340-\374])(.*)', "ReplaceUniChar")
;Return to replace in the string
Return $sShif_UniChars
EndFunc ;==>ReplaceChar_UniChar

Func GetShiftChar($sString)
;Make the GUI out of the monitor
Local $hGUI = GUICreate('', -@DesktopWidth, -@DesktopHeight)
;Create the edit control
Local $iEdit = GUICtrlCreateEdit('', 10, 10)
GUISetState() ;Setting the state is required orelse chars wont be updated

;Split each character into a array
Local $aRet = StringRegExp($sString, '(?s)(.)', 3), $sPrev, $sC

For $i = 0 To UBound($aRet) - 1
;Store the data present in the edit
$sPrev = GUICtrlRead($iEdit)
;Set the data to null
GUICtrlSetData($iEdit, '')
;Send Shifted characters
ControlSend($hGUI, '', $iEdit, "{SHIFTDOWN}" & $aRet[$i] & "{SHIFTUP}")
;Again read the edit
$sC = GUICtrlRead($iEdit)
Switch $sC
Case '' ;If the read data is null
GUICtrlSetData($iEdit, $sPrev & $aRet[$i]) ;Set the data without shifting
Case Else; Else
GUICtrlSetData($iEdit, $sPrev & $sC) ;Set the data with the shifted character
EndSwitch
Next

;Lets read the final output
Local $sRead = GUICtrlRead($iEdit)
;Delete the GUI
GUIDelete()
;Finally return
If $sRead Then Return $sRead
Return $sString
EndFunc ;==>GetShiftChar

Func ReplaceUniChar($sMatch)
;Debug out to Console
ConsoleWrite("UniChar Match:" & $sMatch & @CR)
;Get the ASCII code of the string
$iAscW = AscW($sMatch)
;Return the character preceding the current character by 32
Return ChrW($iAscW - 32)
EndFunc ;==>ReplaceUniChar
You will need to download the UDF again

Hope this satisfies you

Edit: i have added this to the UDF example (4) :P

Regards :)

Edited by PhoenixXL

My code:

PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.

Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners.

MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. 

Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...