Detect Special Character ??

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • RizlaUK
    Indigo Rose Customer
    • May 2006
    • 5552

    Detect Special Character ??

    i need a way of detecting a special character in a string of text

    eg:

    i have a mp3 file with the name "Sweet Family Attitude - 8 Days A Week (10° Below Vs X.Men-Mix).mp3", the char marked in red is the troublesome one

    it seems that my audio engine dosent like special character, it will not play the file or read its id3 tags and i get a error report from the ocx i am useing saying "invalid file", but if i change the name or remove the special char then it works ok but i want to be able to track the fault in the invalid file and inform the user to change the filename (or remove special char)

    any ideas or pointers
    Embrace change in your life, you never know, it could all work out for the best
  • Worm
    Indigo Rose Customer
    • Jul 2002
    • 3971

    #2
    You can search for extended characters by using its ASCII value.



    if String.Find(MP3Name, "\248") ~= -1 then
    --found a bad character
    end

    Comment

    • holtgrewe
      Indigo Rose Customer
      • Jul 2002
      • 779

      #3
      Rizla
      This is pretty lame, but it works...
      just editted ranges of ascii characters.

      Code:
      s1 = Input.GetText("Input1")
      s2=""
      sLen = String.Length(s1)
      for x = 1, sLen do
      	if (String.Mid(s1, x, 1)) == " " or 
      		(String.Mid(s1, x, 1)) == "." or 
      		(String.Mid(s1, x, 1)) == "-" or
      		((String.Mid(s1, x, 1)) > "/" and (String.Mid(s1, x, 1)) < ":") or
      		((String.Mid(s1, x, 1)) > "@" and (String.Mid(s1, x, 1)) < "[") or
      		((String.Mid(s1, x, 1)) > "`" and (String.Mid(s1, x, 1)) < "{")  
      	then
      
      	    s2=s2 .. String.Mid(s1,x,1)
      	else
      		s2=s2 .. "-"
      	end
      end
      
      Input.SetText("Input2", s2)
      Last edited by holtgrewe; 03-28-2008, 01:47 PM.

      Comment

      • azmanar
        Indigo Rose Customer
        • Oct 2004
        • 1020

        #4
        Riz,

        I suggest u use the LUA regex to detect all sorts of special characters.
        Newbie Examples
        ------> AMS 7.5 : amstudio.azman.info
        ----> AMS 6 & 5: www.azman.info/ams/
        ----> FB: facebook.com/GuideToWealth

        ----> Content Development Blog: www.AZMAN.asia

        Comment

        • RizlaUK
          Indigo Rose Customer
          • May 2006
          • 5552

          #5
          thanks guys, i was hoping there was a easy way or ready made dll to catch all special chrs.

          guess i'll have to get busy then, think ill make a dll, for reuseabilty in other apps


          EDIT:

          I suggest u use the LUA regex to detect all sorts of special characters.
          iv been lead to beleave regex is a little complecated, i think i will have a quick research on the subject and see what i can do
          Embrace change in your life, you never know, it could all work out for the best

          Comment

          Working...
          X