Inf Posted December 22, 2013 Share Posted December 22, 2013 (edited) Hi, All! Writing my own "winamp song to text file" script and have problem with striping ID3v1 tags. Got ID3.au3 form >this topic, and it works great except ID3v1 tags — it returns them full 30 bytes length. OK, it's not a problem, stripping all trailing (and leading, if any) spaces with $Artist=StringStripWS(_ID3GetTagField("Artist"),3) $Track=StringStripWS(_ID3GetTagField("Title"),3) $Album=StringStripWS(_ID3GetTagField("Album"),3) It works, but have found 1 mp3 file with ID3v1 tags, which returns trailing Ch(0) instead of Ch(32) (spaces) (have checked it in my generated text file viewing it in hex). And StringStripWS doesn't strips Ch(0) (while help says "Whitespace also includes the null string ( Chr(0) ) and the standard space ( Chr(32) )"). Also checked other ID3v1-only mp3's, and they returns Ch(20), so for now the only idea I have is to ignore such *wrong* mp3's, but I also want to know is there any solution, or did I missed something? Edited December 22, 2013 by Inf Link to comment Share on other sites More sharing options...
l3ill Posted December 22, 2013 Share Posted December 22, 2013 (edited) Hi Inf, and welcome to the Forum! Just a suggestion: Have you tried the $STR_STRIPALL (8) = strip all spaces (over-rides all other flags) Constants are defined in StringConstants.au3 And try running it in BETA Other alternative would be Regexp... Bill Edited December 22, 2013 by l3ill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
Inf Posted December 22, 2013 Author Share Posted December 22, 2013 Hi, l3ill! Thank you for fast reply. I have tried flag=8 ("8 = strip all spaces (over-rides all other flags)") and it also does't strips whitespaces (Ch(0)). Will try in BETA. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 22, 2013 Moderators Share Posted December 22, 2013 Inf,StringReplace will remove the Chr(0) characters for you: #include <StringConstants.au3> $sText = "ASCII" & Chr(0) & "ASCII" & Chr(0) ConsoleWrite(StringToBinary($sText) & @CRLF) $sStripped = StringStripWS($sText, $STR_STRIPALL) ConsoleWrite(StringToBinary($sStripped) & @CRLF) $sReplaced = StringReplace($sText, Chr(0), "") ConsoleWrite(StringToBinary($sReplaced) & @CRLF)Jon has recently altered the way some string functions deal with Chr(0) - I will take a look back at the changes and see if they have affected this function as well. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
mikell Posted December 22, 2013 Share Posted December 22, 2013 Melba, Chr(0) in a string provides strange results, seems 'cancel' the rest of the string $text = "this is " & Chr(0) & " a line of text " MsgBox(0, "", "="& $text &"=") Using 3.3.8.1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 22, 2013 Moderators Share Posted December 22, 2013 mikell,That is perfectly normal as Windows regards Chr(0) as an "end-of-string" marker. In another thread about Chr(0) Jon had this to say recently: "Over time most of the AutoIt string functions have migrated to an internal string object that stores the length so that you can work with strings with nulls in them without too much trouble. Some APIs - like MsgBox - might not show the text correctly but as you've seen in this thread the nulls are usually preserved"This is an entirely diffferent case where Chr(0) is not, contrary to the Help file statement, regarded as "whitespace". If Jon cannot amend the function without causing too many problems elsewhere, the short-term solution is to alter the Help file to remove Chr(0) from the list of characters removed by StringStripWS. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
martin Posted December 22, 2013 Share Posted December 22, 2013 I don't know anything about _ID3GetTagField but I would expect that you need to process the return in some way before using any string functions because chr(0) is used to mark the end of an ascii string, so to me, despite what the Help says, you problem is not surprising. Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script. Link to comment Share on other sites More sharing options...
Inf Posted December 22, 2013 Author Share Posted December 22, 2013 Hi, title="SitringStripWS versus Chr(0): post #4"> Melba23 ! Did my little investigations. Flag=8 strips ALL spaces (even single between words, while help says "To strip single spaces between words, use the function StringReplace()"). So for now i do: $Artist=StringStripWS( StringReplace(_ID3GetTagField("Artist"),Chr(0)," ") ,3) $Track=StringStripWS( StringReplace(_ID3GetTagField("Title"),Chr(0)," ") ,3) $Album=StringStripWS( StringReplace(_ID3GetTagField("Album"),Chr(0)," ") ,3) replacing all Ch(0) with spaces (Ch(32)) and than strip leading and trailing spaces. Thanks to all for your time, spent helping me. Now I'm going for ini-file and GUI Link to comment Share on other sites More sharing options...
Inf Posted December 22, 2013 Author Share Posted December 22, 2013 I don't know anything about _ID3GetTagField but I would expect that you need to process the return in some way before using any string functions because chr(0) is used to mark the end of an ascii string, so to me, despite what the Help says, you problem is not surprising. I'm not sure, what wrong with _ID3GetTagField, but problem in only with ID3v1, and only with some music-files. _ID3GetTagField returns ID3v2 tags without spaces, "ready for use", ID3v1 — with. So, only ID3v1 must be processed, and here comes problem with Ch(0). Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted December 22, 2013 Moderators Share Posted December 22, 2013 Hi, Jon confirms it is not an quick fix so I have opened Trac ticket #2568 for the problem. M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area 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