nacerbaaziz Posted June 22, 2018 Share Posted June 22, 2018 hello Hi dear, I have a question please I designed a function to read the content of the playlist I succeeded in that I have a problem For VLC player playlists If the path of the files in Arabic language the path is be as follows %D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%88%D8%A3%D8%AF%D8%B9%D9%8A%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%85%D9%86%D9%88%D8%B9%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%2003.mp3 I did not know how to decrypt this text to be readable This is the function that i used func M3UImport($M3UFile) dim $AM3UItems local $fileOpen = FileOpen($path, bitOr($FO_OVERWRITE,$FO_CREATEPATH,$FO_ANSI)) _FileReadToArray ($fileOpen, $AM3UItems) if @error then return setError(1) local $M3UPath for $i = 1 to $AM3UItems[0] $AM3UItems[$i] = stringReplace($AM3UItems[$i], "file:///", "") $AM3UItems[$i] = stringReplace($AM3UItems[$i], "/", "\") $AM3UItems[$i] = stringReplace($AM3UItems[$i], "%20", " ") $M3UPath = _fileGetDirPath($AM3UItems[$i]) if $M3UPath = "" then $M3UPath = @WorkingDir if not StringTrimRight($M3UPath, 1) = "\" then $M3UPath &= "\" $AM3UItems[$i] = $M3UPath & $AM3UItems[$i] endIf local $ext = _GetFileExt($AM3UItems[$i]) if fileExists($AM3UItems[$i]) and not (StringInStr($FilesExt, $ext) = 0) then $aListItems[0] += 1 GUICtrlCreateListViewItem(_GetFileName($AM3UItems[$i]) & Opt("GUIDataSeparatorChar") & " : " & Opt("GUIDataSeparatorChar") & $AM3UItems[$i], $list) endIf next return "" endFunc I ask for your help in this work with my Greetings and thanks in advance Link to comment Share on other sites More sharing options...
Danyfirex Posted June 22, 2018 Share Posted June 22, 2018 Hello. maybe something like this: #include <Array.au3> Local $sString = "%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%88%D8%A3%D8%AF%D8%B9%D9%8A%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%85%D9%86%D9%88%D8%B9%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%2003.mp3" MsgBox(0, "", _MakeReadable($sString)) Func _MakeReadable($sString) Local $aReg = StringRegExp($sString, '%[0-9a-fA-F]{2}|.', 3) Local $sChar = "" Local $sReadableString="" For $i = 0 To UBound($aReg) - 1 $sChar = StringReplace($aReg[$i], "%", "") If StringLen($sChar) = 2 Then $sReadableString &= Chr("0x" & $sChar) Else $sReadableString &= $sChar EndIf Next Return BinaryToString(StringToBinary($sReadableString), 4) EndFunc ;==>_MakeTeadable Saludos TheXman 1 Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
nacerbaaziz Posted June 22, 2018 Author Share Posted June 22, 2018 When I used this example, it just gave me as a result the number 3 only Is there a solution please? #include <Array.au3> Local $sString = "%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%88%D8%A3%D8%AF%D8%B9%D9%8A%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%85%D9%86%D9%88%D8%B9%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%2003.mp3" MsgBox(0, "", _MakeReadable($sString)) Func _MakeReadable($sString) Local $aReg = StringRegExp($sString, '%[0-9a-fA-F]{2}|.', 3) Local $sChar = "" Local $sReadableString="" For $i = 0 To UBound($aReg) - 1 $sChar = StringReplace($aReg[$i], "%", "") If StringLen($sChar) = 2 Then $sReadableString = Chr("0x" & $sChar) Else $sReadableString = $sChar EndIf Next Return BinaryToString(StringToBinary($sReadableString), 4) EndFunc am waiting Link to comment Share on other sites More sharing options...
Danyfirex Posted June 22, 2018 Share Posted June 22, 2018 $sReadableString = Chr("0x" & $sChar) needs to be $sReadableString &= Chr("0x" & $sChar) and $sReadableString = $sChar needs to be $sReadableString &= $sChar Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
nacerbaaziz Posted June 22, 2018 Author Share Posted June 22, 2018 I don't understand. Please explain more. Link to comment Share on other sites More sharing options...
Danyfirex Posted June 22, 2018 Share Posted June 22, 2018 check my first code. :-S Saludos Danysys.com AutoIt... UDFs: VirusTotal API 2.0 UDF - libZPlay UDF - Apps: Guitar Tab Tester - VirusTotal Hash Checker Examples: Text-to-Speech ISpVoice Interface - Get installed applications - Enable/Disable Network connection PrintHookProc - WINTRUST - Mute Microphone Level - Get Connected NetWorks - Create NetWork Connection ShortCut Link to comment Share on other sites More sharing options...
nacerbaaziz Posted June 22, 2018 Author Share Posted June 22, 2018 i ded what you tell me but the result is 3 this is the function #include <Array.au3> Local $sString = "%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%88%D8%A3%D8%AF%D8%B9%D9%8A%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%20%D9%85%D9%86%D9%88%D8%B9%D8%A9/%D8%A3%D8%B0%D9%83%D8%A7%D8%B1%2003.mp3" MsgBox(0, "", _MakeReadable($sString)) Func _MakeReadable($sString) Local $aReg = StringRegExp($sString, '%[0-9a-fA-F]{2}|.', 3) Local $sChar = "" Local $sReadableString="" For $i = 0 To UBound($aReg) - 1 $sChar = StringReplace($aReg[$i], "%", "") If StringLen($sChar) = 2 Then $sReadableString = Chr("0x" & $sChar) Else $sReadableString = $sChar EndIf Next Return BinaryToString(StringToBinary($sReadableString), 4) EndFunc Link to comment Share on other sites More sharing options...
TheXman Posted June 23, 2018 Share Posted June 23, 2018 @nacerbaaziz Because you use a screen reader, the ampersands are probably not getting translated correctly because they are immediately before an equal sign. To make the function work correctly, you need to modify 2 lines that were not transcribed correctly. Those 2 lines are below. 21 hours ago, nacerbaaziz said: $sReadableString = Chr("0x" & $sChar) 21 hours ago, nacerbaaziz said: $sReadableString = $sChar On the 2 lines above, there should be an ampersand immediately before the equal sign (without a space in between). The operator should read ampersand equal. I hope that helps. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
nacerbaaziz Posted June 23, 2018 Author Share Posted June 23, 2018 Hello it's worked with me, thank you very much Now I have a simple request if you can help me please the question Is how I can know if the string as this type or normal string I have to make it detect this type so there is no contradiction between the strings types I mean the playlist can be in Arabic and it can be in English I hope that my request is clear for you Greetings Link to comment Share on other sites More sharing options...
TheXman Posted June 23, 2018 Share Posted June 23, 2018 @nacerbaaziz You can either use @Danyfirex's function on all titles to make sure they are converted if necessary or you can search each title for an ampersand followed by 2 numeric digits, and if found, use the function. The safest and most efficient way would be to do the check for the escape sequences and only convert if necessary. CryptoNG UDF: Cryptography API: Next Gen jq UDF: Powerful and Flexible JSON Processor | jqPlayground: An Interactive JSON Processor Xml2Json UDF: Transform XML to JSON | HttpApi UDF: HTTP Server API | Roku Remote: Example Script About Me How To Ask Good Questions On Technical And Scientific Forums (Detailed) | How to Ask Good Technical Questions (Brief) "Any fool can know. The point is to understand." -Albert Einstein "If you think you're a big fish, it's probably because you only swim in small ponds." ~TheXman Link to comment Share on other sites More sharing options...
nacerbaaziz Posted June 23, 2018 Author Share Posted June 23, 2018 I've written the function as this form, please give me your opinion. Func _MakeReadable($sString) Local $aReg = StringRegExp($sString, '%[0-9a-fA-F]{2}|.', 3) Local $sChar = "" Local $sReadableString="" local $number = 0 For $i = 0 To UBound($aReg) - 1 $sChar = StringReplace($aReg[$i], "%", "") If StringLen($sChar) = 2 Then $sReadableString &= Chr("0x" & $sChar) $number += 1 Else $sReadableString &= $sChar $number -= 1 EndIf Next if $number < 2 then return string($sReadableString) else Return BinaryToString(StringToBinary($sReadableString), 4) endIf EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now