Search code examples
ewam

How to remove illegal characters from string in eWam?


Once user enters a data for eg abc$sdfgh% I want to remove the illegal characters from this text.Could someone please suggest me how this can be achieved in eWam?


Solution

  • If you have access to the wyde framework you should option 1. if not please read options 2. and 3.

    1. Use WFTypes methods like RemoveSpaceAndSpecialCharFrom

    WFTypes.RemoveSpaceAndSpecialCharFrom(thisCString)

     function RemoveSpaceAndSpecialCharFrom(thisCString : CString) return CString
        _Result = WFTypes.RemoveSpaceAndSpecialCharFrom(thisCString)
     endFunc 
    
    1. Search for a similar method in the P&C framework
    2. Build your own method something like this:

       function RemoveSpecialCharFrom(thisCString : CString) return CString
          var pCurChar : .Char
      
          _Result = thisCString
          forEach pCurChar in _Result
             switch pCurChar.
                when 'â', 'à'
                   pCurChar. = 'a'
                endWhen
                when 'é', 'ê', 'è'
                   pCurChar. = 'e'
                endWhen
                when 'î', 'ì'
                   pCurChar. = 'i'
                endWhen
                when 'ô', 'ò'
                   pCurChar. = 'o'
                endWhen
                when 'ù', 'û'
                   pCurChar. = 'u'
                endWhen
                when 'ç'
                   pCurChar. = 'c'
                endWhen
                when 'À', 'Â'
                   pCurChar. = 'A'
                endWhen
                when 'È', 'É', 'Ê'
                   pCurChar. = 'E'
                endWhen
                when 'Î', 'Ï', 'Ì'
                   pCurChar. = 'I'
                endWhen
                when 'Ç'
                   pCurChar. = 'C'
                endWhen
                when 'Ô', 'Ò'
                   pCurChar. = 'O'
                endWhen
                when 'Ù', 'Û'
                   pCurChar. = 'U'
                endWhen
                when '/', '\', '(', ')', '.', ',', ';', ':', '?', '-', '&', '$', '[', ']', 
                   '''', '"', '=', '+', '~', '`', '^', '@', '{', '}', '!', '<', '>', '²', 
                   '£', '¤', '%', '°'
                   pCurChar. = '_'
                endWhen
             endSwitch
          endFor
       endFunc