Unicode in SDB title/artist
Unicode in SDB title/artist
Hello
When I try to get the value of a title or an artist (or whatever) from the SDB when in unicode, all I get is question marks.
Is there a way to get the real value of the variables?
Thanks.
When I try to get the value of a title or an artist (or whatever) from the SDB when in unicode, all I get is question marks.
Is there a way to get the real value of the variables?
Thanks.
Re: Unicode in SDB title/artist
Maybe you could be more specific about what you are doing? I've certainly had no problem reading Unicode data from the database and writing it to files, or example.
Download my scripts at my own MediaMonkey fansite.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
All the code for my website and scripts is safely backed up immediately and for free using Dropbox.
Re: Unicode in SDB title/artist
I'm trying to write something that reverses the order of unicode strings inside id3 tags.
When I go to SDB.CurrentSongList and get the Title or the Album, I get "????" instead of letters.
When I go to SDB.CurrentSongList and get the Title or the Album, I get "????" instead of letters.
Re: Unicode in SDB title/artist
Code: Select all
Sub ReverseTags
Dim list, itm, i
' Get list of selected tracks from MediaMonkey
Set list = SDB.CurrentSongList
' Process all selected tracks
For i=0 To list.count-1
Set itm = list.Item(i)
If (itm.BPM <> 1 AND itm.BPM <> 2) Then ' Reverse only if modification flag isn't on yet
itm.Title = ConditionalReverse(itm.Title)
itm.ArtistName = ConditionalReverse(itm.ArtistName)
itm.AlbumArtistName = ConditionalReverse(itm.AlbumArtistName)
itm.Genre = ConditionalReverse(itm.Genre)
itm.Album.Name = ConditionalReverse(itm.Album.Name)
itm.BPM = 1 ' Make sure we won't reverte this file at next startup
End If
Next
' Write all back to DB and update tags
list.UpdateAll
End Sub
' Reverse if string contains Hebrew
Function ConditionalReverse(rev)
If rev = "" Then
ConditionalReverse = rev
End If
Dim i, list, tmp
list = Split(rev)
tmp = rev
For i=0 To UBound(list)
If HasHebrew(list(i)) Then
'MsgBox ("has hebrew")
tmp = StrReverse(rev)
End if
Next
ConditionalReverse = tmp
End Function
' Check if a string contains Hebrew ( = ascii betwee 224-250)
Function HasHebrew(rev)
Dim tmp
tmp = Asc(rev)
If (tmp >= 224 OR tmp <= 250) Then
HasHebrew = true
End If
HasHebew = false
End Function
Re: Unicode in SDB title/artist
Maybe you could try:asaf-g wrote:What happens is, in the function HasHebew(rev) - the tmp variable gets "????" instead of actual chars.
Code: Select all
Function ConditionalReverse(rev)
If rev = "" Then
ConditionalReverse = rev
Else
Dim i, tmp, bHebrew
For i=1 To Len(rev)
tmp = Mid(rev, i, 1)
If HasHebrew(tmp) Then
bHebrew = True
'MsgBox ("has hebrew")
Exit For
End if
Next
If bHebrew = True Then
ConditionalReverse = StrReverse(rev)
Else
ConditionalReverse = rev
End If
End If
End Function
Function HasHebrew(rev)
Dim tmp
tmp = AscW(rev)
If (tmp >= &H590 OR tmp <= &H5FF) Then
HasHebrew = true
Else
HasHebew = false
End If
End Function● Magic Nodes 4.3.3 / 5.2 ● RegExp Find & Replace 4.4.9 / 5.2 ● Invert Selection/Select None 1.5.1 ● Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1 ● Expand Child Nodes/Expand All 1.1.2 ● Event Logger 2.7 ● Filtered Statistics Report 1.6 ● Track Redirection & Synchronization 3.4.2 ● Restore/Synchronize Database 3.1.8 / 4.0.1 ● Find Currently Playing Track 1.3.2 ● Queue List 1.2.1 ● Add to Library on Play 1.0.1 ● Tree Report for Child Nodes 1.1.1 ● Update Location of Files in Database 1.4.5 / 2.3 ● Inherit Child Playlists 1.0.3 ● Add Currently Playing/Selected Track(s) to Playlist 1.2
Re: Unicode in SDB title/artist
Still replaces no matter what (does not consider the if HasHebrew())
When I try to debug (aka pop a msgbox) the variable tmp in the HasHebrew function, I always get 63, which is the ascii code for '?'.
When I try to debug (aka pop a msgbox) the variable tmp in the HasHebrew function, I always get 63, which is the ascii code for '?'.
Re: Unicode in SDB title/artist
Try to add Msgbox rev & vbCr & Mid(rev, i, 1) after the line For i=1 To Len(rev) and post what you got.
● Magic Nodes 4.3.3 / 5.2 ● RegExp Find & Replace 4.4.9 / 5.2 ● Invert Selection/Select None 1.5.1 ● Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1 ● Expand Child Nodes/Expand All 1.1.2 ● Event Logger 2.7 ● Filtered Statistics Report 1.6 ● Track Redirection & Synchronization 3.4.2 ● Restore/Synchronize Database 3.1.8 / 4.0.1 ● Find Currently Playing Track 1.3.2 ● Queue List 1.2.1 ● Add to Library on Play 1.0.1 ● Tree Report for Child Nodes 1.1.1 ● Update Location of Files in Database 1.4.5 / 2.3 ● Inherit Child Playlists 1.0.3 ● Add Currently Playing/Selected Track(s) to Playlist 1.2
Re: Unicode in SDB title/artist
You could also try:
Code: Select all
Function ConditionalReverse(rev)
If rev = "" Then
ConditionalReverse = rev
Else
Dim RE, Matches
Set RE = New RegExp
RE.IgnoreCase = True
RE.Global = True
RE.Pattern = "[\u0590-\u05FF]"
Set Matches = RE.Execute(rev)
If Matches.Count > 0 Then
ConditionalReverse = StrReverse(rev)
Else
ConditionalReverse = rev
End If
End If
End Function● Magic Nodes 4.3.3 / 5.2 ● RegExp Find & Replace 4.4.9 / 5.2 ● Invert Selection/Select None 1.5.1 ● Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1 ● Expand Child Nodes/Expand All 1.1.2 ● Event Logger 2.7 ● Filtered Statistics Report 1.6 ● Track Redirection & Synchronization 3.4.2 ● Restore/Synchronize Database 3.1.8 / 4.0.1 ● Find Currently Playing Track 1.3.2 ● Queue List 1.2.1 ● Add to Library on Play 1.0.1 ● Tree Report for Child Nodes 1.1.1 ● Update Location of Files in Database 1.4.5 / 2.3 ● Inherit Child Playlists 1.0.3 ● Add Currently Playing/Selected Track(s) to Playlist 1.2
Re: Unicode in SDB title/artist
It does show the correct letters + a break-line and the first Hebrew letter of the song title, but it always returns true, even for English only titles.
Re: Unicode in SDB title/artist
This seems to work! I wonder why the other method didn't...ZvezdanD wrote:You could also try:Code: Select all
Function ConditionalReverse(rev) If rev = "" Then ConditionalReverse = rev Else Dim RE, Matches Set RE = New RegExp RE.IgnoreCase = True RE.Global = True RE.Pattern = "[\u0590-\u05FF]" Set Matches = RE.Execute(rev) If Matches.Count > 0 Then ConditionalReverse = StrReverse(rev) Else ConditionalReverse = rev End If End If End Function
And I'm also looking for a way to auto-start this script before and after I start sync-ing my device. Do you know of a way to do that?
Re: Unicode in SDB title/artist
Instead ofasaf-g wrote:It does show the correct letters + a break-line and the first Hebrew letter of the song title, but it always returns true, even for English only titles.
Code: Select all
If (tmp >= &H590 OR tmp <= &H5FF) ThenCode: Select all
If (tmp >= &H590 AND tmp <= &H5FF) Then● Magic Nodes 4.3.3 / 5.2 ● RegExp Find & Replace 4.4.9 / 5.2 ● Invert Selection/Select None 1.5.1 ● Export/Create Playlists for Child Nodes 4.1.1 / 5.4.1 ● Expand Child Nodes/Expand All 1.1.2 ● Event Logger 2.7 ● Filtered Statistics Report 1.6 ● Track Redirection & Synchronization 3.4.2 ● Restore/Synchronize Database 3.1.8 / 4.0.1 ● Find Currently Playing Track 1.3.2 ● Queue List 1.2.1 ● Add to Library on Play 1.0.1 ● Tree Report for Child Nodes 1.1.1 ● Update Location of Files in Database 1.4.5 / 2.3 ● Inherit Child Playlists 1.0.3 ● Add Currently Playing/Selected Track(s) to Playlist 1.2