Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7416341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T07:28:38+00:00 2026-05-29T07:28:38+00:00

I have a field in a table which holds XML entities for special characters,

  • 0

I have a field in a table which holds XML entities for special characters, since the table is in latin-1.
E.g. “Hallöle slovenčina” (the “ö” is in latin-1, but the “č” in “slovenčina” had to be converted to an entity by some application that stores the values into the database)

Now I need to export the table into a utf-8 encoded file by converting the XML entities to their original characters.

Is there a function in Oracle that might handle this for me, or do I really need to create a huge key/value map for that?

Any help is greatly appreciated.

EDIT: I found the function DBMS_XMLGEN.convert, but it only works on <,> and &. Not on &#NNN; 🙁

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T07:28:39+00:00Added an answer on May 29, 2026 at 7:28 am

    I believe the problem with dbms_xmlgen is that there are technically only five XML entities. Your example has a numeric HTML entity, which corresponds with Unicode:

    http://theorem.ca/~mvcorks/cgi-bin/unicode.pl.cgi?start=0100&end=017F

    Oracle has a function UNISTR which is helpful here:

    select unistr('sloven\010dina') from dual;
    

    I’ve converted 269 to its hex equivalent 010d in the example above (in Unicode it is U+010D). However, you could pass a decimal number and do a conversion like this:

    select unistr('sloven\' || replace(to_char(269, 'xxx'), ' ', '0') || 'ina') from dual;
    

    EDIT: The PL/SQL solution:

    Here’s an example I’ve rigged up for you. This should loop over and replace any occurrences for each row you select out of your table(s).

    create table html_entities (
        id NUMBER(3),
        text_row VARCHAR2(100)
    );
    
    INSERT INTO html_entities 
    VALUES (1, 'Hallöle sloven&#269;ina &#266; &#250;');
    
    INSERT INTO html_entities 
    VALUES (2, 'I like the letter &#266;');
    
    INSERT INTO html_entities 
    VALUES (3, 'Nothing to change here.');
    
    DECLARE
        v_replace_str NVARCHAR2(1000);
        v_fh UTL_FILE.FILE_TYPE;       
    BEGIN
        --v_fh := utl_file.fopen_nchar(LOCATION IN VARCHAR2, FILENAME IN VARCHAR2, OPEN_MODE IN VARCHAR2, MAX_LINESIZE IN BINARY_INTEGER);
    
        FOR v_rec IN (select id, text_row from html_entities) LOOP
            v_replace_str := v_rec.text_row;
            WHILE (REGEXP_INSTR(v_replace_str, '&#[0-9]+;') <> 0) LOOP
                v_replace_str := REGEXP_REPLACE(
                    v_replace_str, 
                    '&#([0-9]+);',
                    unistr('\' || replace(to_char(to_number(regexp_replace(v_replace_str, '.*?&#([0-9]+);.*$', '\1')), 'xxx'), ' ', '0')),
                    1,
                    1
                );
            END LOOP;
    
            -- utl_file.put_line_nchar(v_fh, v_replace_str);
            dbms_output.put_line(v_replace_str);
    
        END LOOP;
        --utl_file.fclose(v_fh);
    END;
    /
    

    Notice that I’ve stubbed in calls to the UTL_FILE function to write NVARCHAR lines (Oracle’s extended character set) to a file on the database server. The dbms_output, while great for debugging, doesn’t seem to support extended characters, but this shouldn’t be a problem if you use UTL_FILE to write to a file. Here’s the DBMS_OUTPUT:

    Hallöle slovencina C ú
    I like the letter C
    Nothing to change here.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 1000 records in a table which holds position field starting from 1
I have a database table which holds meta data about images, the field in
I have a field in a table which contains bitwise flags. Let's say for
Hi I have a field in mySql table called jobnumber which auto increments with
i have a project table which has a image_id field and a newsimage_id field.
Let's say I have a Customer table which has a PrimaryContactId field and a
Let's say I have an Order table which has a FirstSalesPersonId field and a
I have requirement like, suppose I have a 'property' table which has 'ListingKey' field
In a SQL server database, I have a table which contains a TEXT field
I have a mysql table field set as time type which stores data in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.