Converting Java String to ascii

后端 未结 2 1134
暗喜
暗喜 2020-12-08 08:01

I need to convert Strings that consists of some letters specific to certain languages (like HÄSTDJUR - note Ä) to a String without those special le

2条回答
  •  执念已碎
    2020-12-08 08:57

    I'd suggest a mapping, of special characters, to the ones you want.

    Ä --> A
    é --> e
    A --> A (exactly the same)
    etc...
    

    And then you can just call your mapping over your text (in pseudocode):

    for letter in string:
       newString += map(letter)
    

    Effectively, you need to create a set of rules for what character maps to the ASCII equivalent.

提交回复
热议问题