non-visible character in modified column

169 Views Asked by At

I have a string, which is arranged in a string without spaces and some characters and without punctuation. In final string is 6 characters "ABCDEF" but length is 7. Why? It is in ORACLE.

select 
 regexp_replace((upper(utl_raw.cast_to_varchar2((nlssort(trim('a.Bc d-E/f'), 'nls_sort=binary_ai'))))), '[/:.,- ]|\d', '') as column_1
,length(regexp_replace((upper(utl_raw.cast_to_varchar2((nlssort(trim('a.Bc d-E/f'), 'nls_sort=binary_ai'))))), '[/:.,- ]|\d', '')) as length_1
from dual

Thanks

1

There are 1 best solutions below

2
On

Looks like utl_raw.cast_to_varchar2() adds the null terminator to the string which LENGTH() counts:

SQL> select
    dump(utl_raw.cast_to_varchar2(nlssort('a.Bc d-E/f', 'nls_sort=binary_ai')
) as column_1
   from dual;

COLUMN_1
-------------------------------------------------------------------------------

Typ=1 Len=11: 97,46,98,99,32,100,45,101,47,102,0

SQL>