The forum will experience an outage sometime between February 10 at 7:00pm EST and February 12 at 11:59 EST for installation of security updates. The actual time and duration of the outage are unknown but attempts will be made to minimize the downtime. We apologize for any inconvenience.

I have a table column of the type TEXT that needs to be parsed with all special dec characters with '?' character. Please provide some information as I am not sure how to handle "UTF-8" bytes.

pseudo code:

select function_name(TEXT_columnName) from table_name;

create function_name(@TEXT_columnname TEXT) returns TEXT as
begin
...
final StringBuilder sb = new StringBuilder();
        try {
            for (byte b : s.getBytes("UTF-8")) {
                if (b < 32 || b > 254) {
                    continue;
                }
                sb.append((char) b);
            }
        } catch (UnsupportedEncodingException e) {
            LOG.error("Unsupported Encoding", e);
        }
        return sb.toString();
end

asked 25 Mar '13, 13:06

hm9m's gravatar image

hm9m
6344
accept rate: 0%

edited 25 Mar '13, 13:11

Mark%20Culp's gravatar image

Mark Culp
22.3k9129262


It looks like you are simply trying to find strings that contain non-ascii characters? If this is correct then look at the patindex function and regexp search condition.

Example: Here is a snippet of code that will raise an exception if a non-printable non-7-bit-ascii character is found in the string @str.

begin
    declare myexception exception for sqlstate 99001;
    if @str not regexp '[[:ascii:]]*' then
        signal myexception;
    end if;
end;

HTH

permanent link

answered 25 Mar '13, 13:29

Mark%20Culp's gravatar image

Mark Culp
22.3k9129262
accept rate: 40%

Thanks for your info!

(25 Mar '13, 15:04) hm9m
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×12
×10

question asked: 25 Mar '13, 13:06

question was seen: 600 times

last updated: 25 Mar '13, 15:04