Application Development 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: 

How to check input supports unicode conversion

Former Member
0 Kudos

Hi Experts ,

I am working on web application using BSP . In my appication i have a input field . i need to validate user input. If user enters any input which is not supports to unicode conversion i need to through an error .Means i need to check for the characters which doesnot support for unicode conversion .

Thanks ,

Vijay

3 REPLIES 3

Former Member
0 Kudos

Hi Vijay,

Your question How to check input supports Unicode conversion sounds a bit odd. The general idea of Unicode is to provide an encoding for almost all characters in different languages. A good start is for example the introduction [What is Unicode|http://www.unicode.org/standard/WhatIsUnicode.html] or the [Unicode FAQ|https://websmp106.sap-ag.de/~sapidb/011000358700002820632002E] from SAP.

Usually you have encoding problems with non-Unicode <a target="_blank" href="http://en.wikipedia.org/wiki/Codepage">code pages</a>, because when you switch among non-Unicode code pages or from Unicode to a non-Unicode code page not all characters supported in your source encoding might be supported in the target encoding.

So if your users are entering Unicode text and your application can handle Unicode, you should be fine. If you're looking for another encoding or a different input check, please post another more specific question.

Cheers, harald

0 Kudos

Hi Harald,

I got same requirement for unicode - my requirement is To Check if the import parameter contains some unicode characters and throw an exception.

I found one class i.e cl_umg_word=>non_7bit_ascii_check(Check for non 7 bit ascii characters (Static Method)) this class is for not working for 8 bit ascii characters.I need a class to for Check for non 8 bit ascii characters.

Could you please help me on the above requirement.

Thanks,

Shan

0 Kudos

Hi Shan,

Please check what your actual requirements are. It doesn't make sense

to check if the import parameter contains some unicode characters

Unicode is just a special way of encoding characters. I.e. on the computer you have a sequence of bytes or integers and they need to be interpreted as characters. Thus you need a mapping from byte/integer to a character. That's what is called [character encoding|http://en.wikipedia.org/wiki/Character_encoding] or <a target="_blank" href="http://en.wikipedia.org/wiki/Code_page">code page</a> (the latter term you probably encounter more often in the SAP context).

Depending on the chosen encoding you can represent different characters; Unicode attempts to be an encoding that encompasses all characters of common languages and often used symbols. Other code pages don't contain all possible characters, but are rather specific to a subset of some languages or a single language. E.g. the classic [US-ASCII|http://en.wikipedia.org/wiki/ASCII] is a simple encoding that basically covers English language (characters, digits and punctuation).

So if you have a string that is encoded in Unicode, each individual character will be a Unicode character. However, if your goal was to possibly allow only US-ASCII characters, because you want to convert your encoding from Unicode to US-ASCII (e.g. because you need to transfer data to an application that is not Unicode-enabled or uses a different code page than your current one), then you'd' need to check if your Unicode string contains only characters that can be represented in US-ASCII.

Note that in Unicode you have an organization into [character planes|http://en.wikipedia.org/wiki/Mapping_of_Unicode_character_planes], which in turn contain scripts and symbols. Also, there's different Unicode encodings out there (UTF-8, UTF-16, ...), but essentially they are all equivalent, because they all can be mapped without loosing any characters during conversion.

Anyhow, basically both of you want to create some input check. To limit input characters you could either use regular expressions or attempt a code conversion towards your target code page and issue an error if that doesn't work. For the latter check SDN for references of ABAP class CL_ABAP_CONV_OUT_CE and CL_ABAP_CONV_IN_CE. There's lots of material out there...

Cheers, harald