Irfan's World

January 25, 2011

What is Unicode and non Unicode data formats?

Filed under: Data Warehouse — Tags: , — Irfan @ 12:33 am

In my earlier post, I have explained about data. In this post, I am going to explain you some basics about Unicode and non Unicode formats:

Unicode :
A Unicode character takes more bytes to store the data in the database. As we all know, many global industries wants to increase their business worldwide and grow at the same time, they would want to widen their business by providing services to the customers worldwide by supporting different languages like Chinese, Japanese, Korean and Arabic. Many websites these days are supporting international languages to do their business and to attract more and more customers and that makes life easier for both the parties.

To store the customer data into the database the database must support a mechanism to store the international characters, storing these characters is not easy, and many database vendors have to revised their strategies and come up with new mechanisms to support or to store these international characters in the database. Some of the big vendors like Oracle, Microsoft, IBM and other database vendors started providing the international character support so that the data can be stored and retrieved accordingly to avoid any hiccups while doing business with the international customers.

The difference in storing character data between Unicode and non-Unicode depends on whether non-Unicode data is stored by using double-byte character sets. All non-East Asian languages and the Thai language store non-Unicode characters in single bytes. Therefore, storing these languages as Unicode uses two times the space that is used specifying a non-Unicode code page. On the other hand, the non-Unicode code pages of many other Asian languages specify character storage in double-byte character sets (DBCS). Therefore, for these languages, there is almost no difference in storage between non-Unicode and Unicode.

Encoding Formats:
Some of the common encoding formats for Unicode are UCS-2, UTF-8, UTF-16, UTF-32 have been made available by database vendors to their customers. For SQL Server 7.0 and higher versions Microsoft uses the encoding format UCS-2 to store the UTF-8 data. Under this mechanism, all Unicode characters are stored by using 2 bytes.

Unicode data can be encoded in many different ways. UCS-2 and UTF-8 are two common ways to store bit patterns that represent Unicode characters. Microsoft Windows NT, SQL Server, Java, COM, and the SQL Server ODBC driver and OLEDB provider all internally represent Unicode data as UCS-2.

The options for using SQL Server 7.0 or SQL Server 2000 as a backend server for an application that sends and receives Unicode data that is encoded as UTF-8 include:

For example, if your business is using a website supporting ASP pages, then this is what happens:

If your application uses Active Server Pages (ASP) and you are using Internet Information Server (IIS) 5.0 and Microsoft Windows 2000, you can add "<% Session.Codepage=65001 %>" to your server-side ASP script. This instructs IIS to convert all dynamically generated strings (example: Response.Write) from UCS-2 to UTF-8 automatically before sending them to the client.

If you do not want to enable sessions, you can alternatively use the server-side directive "<%@ CodePage=65001 %>".

Any UTF-8 data sent from the client to the server via GET or POST is also converted to UCS-2 automatically. The Session.Codepage property is the recommended method to handle UTF-8 data within a web application. This Codepage setting is not available on IIS 4.0 and Windows NT 4.0.

Sorting and other operations :

The effect of Unicode data on performance is complicated by a variety of factors that include the following:

1. The difference between Unicode sorting rules and non-Unicode sorting rules
2. The difference between sorting double-byte and single-byte characters
3. Code page conversion between client and server

Performing operations like >, <, ORDER BY are resource intensive and will be difficult to get correct results if the codepage conversion between client and server is not available.

Sorting lots of Unicode data can be slower than non-Unicode data, because the data is stored in double bytes. On the other hand, sorting Asian characters in Unicode is faster than sorting Asian DBCS data in a specific code page, because DBCS data is actually a mixture of single-byte and double-byte widths, while Unicode characters are fixed-width.

Non-Unicode :

Non Unicode is exactly opposite to Unicode. Using non Unicode it is easy to store languages like ‘English’ but not other Asian languages that need more bits to store correctly otherwise truncation will occur.

Now, let’s see some of the advantages of not storing the data in Unicode format:

1. It takes less space to store the data in the database hence we will save lot of hard disk space.
2. Moving of database files from one server to other takes less time.
3. Backup and restore of the database makes huge impact and it is good for DBA’s that it takes less time

Non-Unicode vs. Unicode Data Types: Comparison Chart

The primary difference between unicode and non-Unicode data types is the ability of Unicode to easily handle the storage of foreign language characters which also requires more storage space.

Non-Unicode Unicode
(char, varchar, text) (nchar, nvarchar, ntext)
Stores data in fixed or variable length Same as non-Unicode
char: data is padded with blanks to fill the field size. For example, if a char(10) field contains 5 characters the system will pad it with 5 blanks nchar: same as char
varchar: stores actual value and does not pad with blanks nvarchar: same as varchar
requires 1 byte of storage requires 2 bytes of storage
char and varchar: can store up to 8000 characters nchar and nvarchar: can store up to 4000 characters
Best suited for US English: "One problem with data types that use 1 byte to encode each character is that the data type can only represent 256 different characters. This forces multiple encoding specifications (or code pages) for different alphabets such as European alphabets, which are relatively small. It is also impossible to handle systems such as the Japanese Kanji or Korean Hangul alphabets that have thousands of characters."1 Best suited for systems that need to support at least one foreign language: "The Unicode specification defines a single encoding scheme for most characters widely used in businesses around the world. All computers consistently translate the bit patterns in Unicode data into characters using the single Unicode specification. This ensures that the same bit pattern is always converted to the same character on all computers. Data can be freely transferred from one database or computer to another without concern that the receiving system will translate the bit patterns into characters incorrectly.

I think I should stop here, I will go on writing otherwise.



  1. very good and clear description,
    Thanks a lot

    Comment by Nandhni — May 19, 2011 @ 7:35 am

    • You are welcome.!!

      Comment by Irfan — May 19, 2011 @ 4:09 pm

  2. very good information..

    Comment by Bala — July 10, 2012 @ 11:37 pm

  3. good explanation

    Comment by moudhani — September 10, 2012 @ 5:48 am

  4. Thanks for the neat post !

    Comment by Ram — October 2, 2012 @ 9:25 am

  5. Wonderful..clean and crisp!
    Thanks a lot..

    Comment by NK — January 4, 2013 @ 12:15 pm

  6. Thanks a lot…

    Comment by sukhdev — February 17, 2013 @ 1:10 pm

    • Thanks for stopping by.

      Comment by Irfan — February 24, 2013 @ 9:26 am

  7. This make my concept clear…
    Thanks a lot…

    Comment by Ashish jain — February 19, 2013 @ 9:40 am

    • Thanks for stopping by.

      Comment by Irfan — February 24, 2013 @ 9:25 am

  8. good explanation. but i ve a question, are the characters(such as letters,numbers,symbols) from unicode & characters from non-unicode same?

    Comment by Shank — May 12, 2013 @ 10:20 am

  9. Very good Explaination

    Comment by Mubassir — June 30, 2013 @ 11:36 pm

  10. Thanks Boss

    Comment by ehtesham — March 24, 2014 @ 12:25 am

  11. nice

    Comment by pavitha — May 6, 2014 @ 1:11 am

  12. Gud one.

    Comment by Shree — June 6, 2014 @ 4:57 am

  13. good ….!! easy to understand!

    Comment by Najna Abdulla — July 16, 2014 @ 10:12 pm

  14. Thanks

    Comment by Srinikg — July 27, 2015 @ 12:25 pm

  15. Clear explanation

    Comment by bkselvan — August 11, 2015 @ 6:06 am

  16. Now i am clear about unicode and non unicode——Thanks a lot.

    Comment by Kamal — December 17, 2015 @ 6:53 am

  17. Good explanation

    Comment by Kiran Reddy — December 30, 2015 @ 8:30 am

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: