ü ä ö ... getCorrectedStringUAOSS Topic is solved

Get help with using AutoHotkey and its commands and hotkeys
User avatar
SL5
Posts: 860
Joined: 12 May 2015, 02:10
GitHub: sl5net
Contact:

ü ä ö ... getCorrectedStringUAOSS

01 Mar 2018, 07:09

Tests 1 (hept tool: Notepadd++):
Text Source Format is: UTF-8 ohne BOM
AHK Souce Formatis: ANSI

Tests 2:
Text Source Format is: UTF-8 ohne BOM
AHK Souce Formatis: UTF-8 ohne BOM

if i test with a little demo script, it will all öä correct.
if i use it with the big script it does not convert correct.
strange :eh:

Code: Select all

#SingleInstance,force

content1 := ""
content2 := ""
content3 := ""
fileAddress = tempTestFile.txt
FileRead,content1,% fileAddress 
Loop,9999
{
	FileReadLine, thisLine , %fileAddress%, %A_Index%
	content2 .= thisLine . A_Index . "`n"
	if ErrorLevel
		break
}
Loop, Read, %fileAddress%
	content3 .= A_LoopReadLine . " A_Index=" . A_Index . "`n"
msg= 0: %content1% `n
msg .= "_____`n"
msg .= "1: getCorrectedStringUAOSS = " . getCorrectedStringUAOSS( content1  ) . "`n"
msg .= "2: getCorrectedStringUAOSS = " . getCorrectedStringUAOSS( content2  ) 
msg .= "3: getCorrectedStringUAOSS = " . getCorrectedStringUAOSS( content3  ) 
MsgBox,% msg

ExitApp

getCorrectedStringUAOSS( sending  ) {
sending := RegExReplace( sending , "i)ü", Chr(252) ) ; ue http://slayeroffice.com/tools/ascii/
sending := RegExReplace( sending , "Ü", Chr(220) ) ; UE http://slayeroffice.com/tools/ascii/ Übrigens
sending := RegExReplace( sending , "ueber", "" . Chr(252) .  "ber" ) ; ue http://slayeroffice.com/tools/ascii/
sending := RegExReplace( sending , "i)\bfür\b","f" . Chr(252) . "r") ; ue http://slayeroffice.com/tools/ascii/
sending := RegExReplace( sending , "i)\bgründ","gr" . Chr(252) . "nd") ; ue http://slayeroffice.com/tools/ascii/
sending := RegExReplace( sending , "i)\bmuendl.\b","m" . Chr(252) . "uendl.") ; ue http://slayeroffice.com/tools/ascii/

sending := RegExReplace( sending , "ö", Chr(246) ) ; oe zB hören http://slayeroffice.com/tools/ascii/
sending := RegExReplace( sending , "oe", Chr(246) ) ; oe zB hören http://slayeroffice.com/tools/ascii/


; weiß
sending := RegExReplace( sending , "ß","" . Chr(223) . "") ; ss http://slayeroffice.com/tools/ascii/
sending := RegExReplace( sending , "i)\bgroß","gro" . Chr(223) . "") ; ss http://slayeroffice.com/tools/ascii/
sending := RegExReplace( sending , "i)ließlich\b","lie" . Chr(223) . "lich") ; scharfess http://slayeroffice.com/tools/ascii/ ausschließlich
; sending := RegExReplace( sending , "i)ss", Chr(223) ) ; scharfess http://slayeroffice.com/tools/ascii/ Ausnahmen professionell

sending := RegExReplace( sending , "i)ä", Chr(228) ) ; ae http://slayeroffice.com/tools/ascii/ ausschließlich
sending := RegExReplace( sending , "Ä", "" . Chr(196) . "" ) ; AE http://slayeroffice.com/tools/ascii/
sending := RegExReplace( sending , "u.Ä.", "u." . Chr(196) . "." ) ; AE http://slayeroffice.com/tools/ascii/
sending := RegExReplace( sending , "i)beschäftigte","besch" . Chr(228) . "ftigte ") ; ae http://slayeroffice.com/tools/ascii/ ausschließlich
sending := RegExReplace( sending , "i)Aufträge","Auftr" . Chr(228) . "ge") ; ae http://slayeroffice.com/tools/ascii/ ausschließlich

foundPos := RegExMatch( sending , "i)Ã" )
;~ foundPos := RegExMatch( "str" , "i)für" )
if(foundPos){
msgbox,17-05-23_17-09 :( '%sending%' = sending  (line:%A_LineNumber%) n )
}


return sending  
}

User avatar
SL5
Posts: 860
Joined: 12 May 2015, 02:10
GitHub: sl5net
Contact:

Re: ü ä ö ... getCorrectedStringUAOSS

01 Mar 2018, 10:07

for this workaround i need to copy the text manually to the clipboard and paste it.

another posibility also works.
sending the text with a https://hotkeyit.github.io/v2/docs/commands/DynaRun.htm

Code: Select all

OnClipboardChange:

if(A_EventInfo=2)
  ClipboardIsBinary:=1
else
  ClipboardIsBinary:=0
if(A_EventInfo <> 1) ; can expressed as text. includes files copied from an Explorer window
    return
if(ClipboardIsBinary)
  return

; something that can be expressed as text (this includes files copied from an Explorer window);
;Nightly ahk_class CabinetWClass

Clipboard := getCorrectedStringUAOSS( Clipboard )
return
Last edited by SL5 on 01 Mar 2018, 11:02, edited 1 time in total.
User avatar
jeeswg
Posts: 6819
Joined: 19 Dec 2016, 01:58
Location: UK

Re: ü ä ö ... getCorrectedStringUAOSS

01 Mar 2018, 10:58

Does this work for you?

Code: Select all

q:: ;UTF-8 bytes to text
vText := Chr(8730) ;square root symbol
MsgBox, % vUtf8Bytes := JEE_StrTextToUtf8Bytes(vText)
MsgBox, % vText := JEE_StrUtf8BytesToText(vUtf8Bytes)
return

;==================================================

;e.g. vText := JEE_StrUtf8BytesToText(vUtf8Bytes)

JEE_StrUtf8BytesToText(ByRef vUtf8Bytes)
{
	if A_IsUnicode
	{
		VarSetCapacity(vTemp, StrPut(vUtf8Bytes, "CP0"))
		StrPut(vUtf8Bytes, &vTemp, "CP0")
		return StrGet(&vTemp, "UTF-8")
	}
	else
		return StrGet(&vUtf8Bytes, "UTF-8")
}

;==================================================

;e.g. vUtf8Bytes := JEE_StrTextToUtf8Bytes(vText)

JEE_StrTextToUtf8Bytes(ByRef vText)
{
	VarSetCapacity(vTemp, StrPut(vText, "UTF-8"))
	StrPut(vText, &vTemp, "UTF-8")
	return StrGet(&vTemp, "CP0")
}

;==================================================
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
User avatar
SL5
Posts: 860
Joined: 12 May 2015, 02:10
GitHub: sl5net
Contact:

Re: ü ä ö ... getCorrectedStringUAOSS

01 Mar 2018, 11:09

02.03.2018 09:33 deleted this partial contribution. worthless, hurts the clarity
Last edited by SL5 on 02 Mar 2018, 03:34, edited 1 time in total.
User avatar
SL5
Posts: 860
Joined: 12 May 2015, 02:10
GitHub: sl5net
Contact:

Re: ü ä ö ... getCorrectedStringUAOSS  Topic is solved

01 Mar 2018, 11:11

jeeswg wrote:Does this work for you? ...
yes JEE_StrUtf8BytesToText works :)

sending := JEE_StrUtf8BytesToText( sending )

Return to “Ask For Help”

Who is online

Users browsing this forum: Antoine, Bort P, CheshireCat, flyingDman, guest3456, JKnight_xbt33, Verminaard and 206 guests