in Advanced 

Resource preview: Know-how

HomeResource preview:
Log in

Represent non-breaking dash and space in Oracle

We want a telephone number to stay unbreakable in HTML, we don't want it breaked to 2 rows!

For example our data comes from Oracle and is displayed in HTML.
We don't want the telephone number 1-800-000-000 breaked in two rows.
And also for this variant '1 800 000 000' we want to see all the digits together on one row.
We need then the symbol called NON-BREAKING SPACE and the symbol NON-BREAKING HYPHEN (DASH).
The functions CHR() and NCHR from Oracle(Oracle database) does not suit our needs as they take the client encoding into account. I post some variants for dashes and spaces just for completeness:

FOO BAR U+00A0 NON-BREAKING SPACE  
FOO-BAR U+002D HYPHEN-MINUS  
FOO­BAR U+00AD SOFT HYPHEN  
FOO‐BAR U+2010 HYPHEN  
FOO‑BAR U+2011 NON-BREAKING HYPHEN  
FOO‒BAR U+2012 FIGURE DASH  
FOO–BAR U+2013 EN DASH  
FOO—BAR U+2014 EM DASH 


The result is:
FOO BAR
FOO-BAR
FOO­BAR
FOO‐BAR
FOO‑BAR
FOO‒BAR
FOO–BAR
FOO—BAR

For our purpose there is another function in Oracle called unistr(), which is not available in Oracle 8. This function allows if your database uses ASCII to enter an unicode symbol.
Here is how it works in our case:
select 'FOO'||unistr('\2011')||'BAR' from dual;
----------------------------------------------------
FOO‑BAR

select 'FOO'||unistr('\00A0')||'BAR' from dual;
----------------------------------------------------
FOO BAR

select unistr('1\2011800\2011000\2011000') from dual;
----------------------------------------------------
1‑800‑000‑000

select unistr('1\00A0800\00A0000\00A0000') from dual;
----------------------------------------------------
1 800 000 000




Useful links:
http://www.querytool.com/help/907.htm
http://en.wikipedia.org/wiki/Non-breaking_space
Vote:
Comments: 0
Please vote! Your opinion matters!
If you want to share knowledge with the others, post a resource
Add resource
Related resources:
| Home | Hall of fame | Registration | Log in | Terms of service | Privacy policy | Help | Contacts | RSS |