Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Unsigned Unicode problem

chau1995
Active Participant
0 Likes
1,077

Hi all,

I have a problem with unicode character,

Assume that I have a string: 'Tôi Dễ Thương'

I want to convert this string to: 'Toi De Thuong'

Could anybody has a function module or algorithm which cover to all case to resolve this problem.

Thanks so much

4 REPLIES 4
Read only

Sandra_Rossi
Active Contributor
860

There is the function module SCP_REPLACE_STRANGE_CHARS. Maybe not all characters are taken into account or not as you wish, but you may copy it and adapt it (and maybe simplify it).

Read only

chau1995
Active Participant
0 Likes
860

In case i want to remove vietnamese accents, If i use this fm, some case was not good, i mean it were disappeared character

Read only

860

Please use the COMMENT button for comments, questions, adding details, etc., ANSWER is only to propose a solution, dixit SAP text at the right of the answer area: "Before answering You should only submit an answer when you are proposing a solution to the poster's problem"

Read only

Sandra_Rossi
Active Contributor
860

A simple solution is to list all possible characters and use TRANSLATE (or translate for ABAP 7.40 and above).

You may list all possible characters by looking at table TCPUCATTR, all characters associated to "A" can be found by looking for * CAPITAL LETTER A *, "a" by looking for * SMALL LETTER A *, etc.

This code lists the translation letters for TRANSLATE:

DATA c1 TYPE c LENGTH 1.
DATA x2 TYPE x LENGTH 2.
DATA(upper_lower) = sy-abcde && to_lower( sy-abcde ).
SELECT * FROM tcpucattr
    WHERE charid LIKE '00%'
      AND attrkind = 'N'
      AND ( attr LIKE '%SMALL LETTER%' OR attr LIKE '%CAPITAL LETTER%' )
    INTO TABLE @DATA(tcpucattr_s).
DO 52 TIMES.
  DATA(letter) = substring( val = upper_lower off = sy-index - 1 len = 1 ).
  IF sy-index <= 26.
    DATA(pattern_attr) = |* CAPITAL LETTER { to_upper( letter ) } *|.
  ELSE.
    pattern_attr = |* SMALL LETTER { to_upper( letter ) } *|.
  ENDIF.
  DATA(letters) = ``.
  WRITE : / letter, ':'.
  LOOP AT tcpucattr_s ASSIGNING FIELD-SYMBOL(<tcpucattr>) WHERE attr CP pattern_attr.
    x2 = <tcpucattr>-charid+2.
    c1 = cl_abap_conv_in_ce=>uccp( x2 ).
    IF c1 <> letter.
      WRITE : c1 NO-GAP, letter NO-GAP.
    ENDIF.
  ENDLOOP.
ENDDO.

PS: characters of type "combining accent" can be simply removed (all with text "COMBINING" in TCPUCATTR).