Home AMX User Forum NetLinx Studio

Unicode Support

Hello all,

Hope this is the right place to post this,
I have a module that i wrote some time ago to the Russound SMS3 mp3 audio serevr that works fine.
I have a new project that involves some MP3 files in Russian.
when they are being showed on the MVP-7500 they look like $%&%$, so i understand that it's because i need to use Unicode.
After looking in the MVP manual i see the command "^UNI", but with this command i will have to write a whole new module....
isn't there another way to deal with unicode in a simpler way? because this isn't "Unicode Support".....

Thank you

Comments

  • frthomasfrthomas Posts: 176
    I do not get the question. I think you just have to use the UNI thingy instead of whatever you are currently using to send strings to the panels.

    If by entirely different module you mean one that works in latin1 and another in Unicode, then blame it on Russound that should be able to ALWAYS return Unicode and on AMX to support UTF-16 and not utf8 that could have offered ASCII support out of the box.

    One thing to check is what is the Russound encoding of the russian strings as the MVP will expect UTF-16 (not sure of the flavour). Should Russound export utf8 (likely), then a conversion is necessary.

    HTH

    Fred
  • Chip MoodyChip Moody Posts: 727
    A Unicode string is unfortunately not "plug n play" ready for the UNI command.

    Ronen, let me know if this helps:
    DEFINE_FUNCTION CHAR[200] DeUTF (CHAR Msg[1024])
    {
    (* UTF-8 encoding:
     bytes | bits | representation
         1 |    7 | 0vvvvvvv
         2 |   11 | 110vvvvv 10vvvvvv
         3 |   16 | 1110vvvv 10vvvvvv 10vvvvvv
         4 |   21 | 11110vvv 10vvvvvv 10vvvvvv 10vvvvvv
    *)
      LOCAL_VAR CHAR UnUTF[1024]
      LOCAL_VAR INTEGER x  
      LOCAL_VAR LONG Unicode 
      
      UnUTF = ''
      x = 1
      WHILE (x <= LENGTH_STRING(Msg))
      {
        IF (Msg[x] > $7F)
        {
          Unicode = 0
          SELECT
          {
            ACTIVE (((Msg[x] >> 5) = $6) AND ((x+1) <= LENGTH_STRING(Msg))):
    	{
    	  IF ((Msg[x+1] >> 6) = 2)
    	  {
    	    Unicode = ((Msg[x] BAND $1F) << 6) + (Msg[x+1] BAND $3F)
    	    x = x + 1
    	  }
    	}
    	ACTIVE (((Msg[x] >> 4) = $E) AND ((x+2) <= LENGTH_STRING(Msg))):
    	{
    	  IF (((Msg[x+1] >> 6) = 2) AND ((Msg[x+2] >> 6) = 2))
    	  {
    	    Unicode = ((Msg[x] BAND $F) << 12) + ((Msg[x+1] BAND $3F) << 6) + (Msg[x+2] BAND $3F)
    	    x = x + 2
    	  }
    	}
            ACTIVE  ((Msg[x] >> 3 = $1E) AND ((x+3) <= LENGTH_STRING(Msg))):
    	{
    	  IF (((Msg[x+1] >> 6) = 2) AND ((Msg[x+2] >> 6) = 2) AND ((Msg[x+3] >> 6) = 2))
    	  {
    	    Unicode = ((Msg[x] BAND $7) << 18) + ((Msg[x+1] BAND $3F) << 12) + ((Msg[x+2] BAND $3F) << 6) + (Msg[x+3] BAND $3F)
    	    x = x + 3
    	  }
    	}
          }
        }
        ELSE
        {
          Unicode = Msg[x]
        }
        IF (Unicode < $20) Unicode = UnicodeReplacementChar[1]
        ELSE IF (Unicode > $FFFF) Unicode = UnicodeReplacementChar[1]
        IF (PanelVer = G3)
        {
          IF (Unicode < $100) UnUTF = "UnUTF,(Unicode BAND $FF)"
          ELSE UnUTF = "UnUTF,UnicodeReplacementChar"
        }
        ELSE IF (PanelVer = G4)
        {
          UnUTF = "UnUTF,RIGHT_STRING("'000',ITOHEX(Unicode)",4)"
        }
        x = x + 1
      }
      IF (LENGTH_STRING(UnUTF))
      {
        IF (PanelVer = G3)
        {
          IF (UnUTF[LENGTH_STRING(UnUTF)] = UnicodeReplacementChar) SET_LENGTH_STRING(UnUTF,(LENGTH_STRING(UnUTF)-1))
        }
        ELSE IF (PanelVer = G4)
        {
          IF (RIGHT_STRING(UnUTF,4) = RIGHT_STRING("'000',ITOHEX(UnicodeReplacementChar[1])",4)) SET_LENGTH_STRING(UnUTF,(LENGTH_STRING(UnUTF)-4))
        }
      }
      RETURN UnUTF
    }
    

    This was written to take a UTF string and format it for either a G3 panel or a G4 panel, based on the "PanelVer" variable set elsewhere in the program. For a G3 panel, the "UnicodeReplacementChar" is a single character (I used an underscore) that would be substituted anywhere a character outside the G3 panel's character set might appear.

    I'd call this routine with something like this:
    DEFINE_FUNCTION INTEGER ButtonUniText (DEV Panel[],INTEGER Button,CHAR NewText[])
    {
      IF (PanelVer = G3) {SEND_COMMAND Panel,"'@TXT',Button,DeUTF(NewText)"}
      ELSE IF (PanelVer = G4) {SEND_COMMAND Panel,"'^UNI-',ITOA(Button),',1.255,',DeUTF(NewText)"}
    }
    

    - Chip
  • DHawthorneDHawthorne Posts: 4,584
    I'm not altogether confident what the Russound is spitting out is pure unicode either. I think they may employ an undocumented meta code, I've had to filter the display strings to prevent strange characters from appearing on my panel in what should have been pure ASCII English. This was with the XM tuner, mind you, not the MP3 player, but they are probably the same control-wise.
  • RonenRonen Posts: 55
    Chip, thanks for the code sample i will try it soon.
  • RonenRonen Posts: 55
    success!

    Chip, thanks alot, worked great with the Russian.
    with the hebrew there is still a little problem:
    because hebrew is a languge that is writen right to left it will show the words backwords, so i will try to change your function a bit, hope i will solve the problem.

    thank you again
  • Chip MoodyChip Moody Posts: 727
    Glad it worked, and good luck with the Hebrew fix! Sounds like an interesting challenge.

    - Chip
  • Chip MoodyChip Moody Posts: 727
    Ah yes, those wonderful "undocumented features" manufacturers like to put in their products. :)

    If you trip across any examples of those characters, I could probably tell you if it's UTF-8 or not. UTF-8 multi-byte characters being sent straight to a TP would certainly explain the appearance of odd characters here and there. Were thre always at least two characters each time?

    - Chip

    DHawthorne wrote:
    I'm not altogether confident what the Russound is spitting out is pure unicode either. I think they may employ an undocumented meta code, I've had to filter the display strings to prevent strange characters from appearing on my panel in what should have been pure ASCII English. This was with the XM tuner, mind you, not the MP3 player, but they are probably the same control-wise.
Sign In or Register to comment.