Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register


1
(click on this box to dismiss)

Khmer Unicode Support?

I want to use ADO.NET connect to CUBRID 9 and store "khmer unicode" data.

How could I config CUBRID to support Khmer Unicode.

link comment (0)
asked 10 months ago
phath
6
2 Answers
1

CUBRID 9.1 supports Khmer Unicode character set. This Cambodian character set is not one of the built-in which is why you need to run the following commands to tell CUBRID to use the Cambodian character set. By default CUBRID loads English, Korean and Turkish locales.

I will assume the following:

  1. That you have already installed CUBRID at /opt/cubrid. If it's a different location, use your location in the following commands.
  2. That CUBRID binaries in /opt/cubrid/bin are available in your $PATH.

Set a non-builtin locale (Khmer Unicode)

Considering the above, do the following in order to set Khmer Unicode character set.

  1. If CUBRID is installed in /opt/cubrid, open /opt/cubrid/conf/cubrid_locales.txt file in your text editor and add the following line at the end of the file.
    # <lang_name>   <LDML file>                                     <lib file>
    km_KH           /opt/cubrid/locales/data/ldml/cubrid_km_KH.xml  /opt/cubrid/lib/libcubrid_all_locales.so
    This file tells CUBRID which locales to load when CUBRID Server starts. 
  2. Now check if your CUBRID is 32 or 64 bit.
    # cubrid --version
    cubrid (CUBRID utilities)
    CUBRID 9.1 (9.1.0.0212) (64bit release build for linux_gnu) (Mar 14 2013 00:16:33)
    Copyright (C) 2008 Search Solution Corporation. All rights reserved by Search Solution.
    The above output says that CUBRID Server is 64 bit.
  3. Now we need to compile our Khmer locale so that CUBRID Server can load it. If your CUBRID is also 64 bit, then run:
    # make_locale.sh -t 64
     Running /opt/cubrid/bin/make_locale.sh with parameters:
             BUILD_TARGET    = 64bit
             BUILD_MODE      = release
             SELECTED_LOCALE = all_locales
    
    Generating locale C file for all_locales
    Compiling locale library
    Building shared object for platform 64bit, in release mode, with tag all_locales
    Done.
    Moving /opt/cubrid/locales/loclib/libcubrid_all_locales.so to /opt/cubrid/lib
    Done.
    Removing locale C source file /opt/cubrid/locales/loclib/locale.c
    Done.
    The library for selected locale(s) has been created at /opt/cubrid/lib/libcubrid_all_locales.so
    To check compatibility and synchronize your existing databases, run:
    cubrid synccolldb <database-name>
    If CUBRID is 32 bit, then run the same command without options:
    make_locale.sh
  4. Finally, we need to set the CUBRID_CHARSET environment variable which is used by CUBRID Server. If you are logged in as root user, then edit /root/.profile file. If you are logged in as another user, then edit /home/username/.profile file. At the end of the file define our environment variable.
    export CUBRID_CHARSET=km_KH.utf8
    export intl_date_lang=km_KH
  5. Then run the following, depending on your user, to apply the environment variable. You need to do this only once, since every next time when you login, these variables will be applied automatically.
    # source /root/.profile
    Or
    #source /home/username/.profile
  6. Let's check if our environment variables are correctly set.
    # echo $CUBRID_CHARSET
    km_KH.utf8
    It correctly shows that km_KH.utf8 locale is set as default.

These are the steps to enable not-builtin locale. You should do this only once.

Perform the check

To check that the locale has been successfully applied, run the following command.

# cubrid dumplocale km_KH
*************************************************
Locale data for: km_KH
Library file: /opt/cubrid/lib/libcubrid_all_locales.so
Locale string: km_KH
Locale checksum: d79362f7e607ad6aaaeea79261096d71

We can notice that Khmer locale has been successfully loaded, and it tells us where the locale library is stored.

If you are interested, you can output a more detailed information about the Khmer locale as shown below. This tells how dates and other things used in Khmer locale.

# cubrid dumplocale -d km_KH
*************************************************
Locale data for: km_KH
Library file: /opt/cubrid/lib/libcubrid_all_locales.so
Locale string: km_KH
Locale checksum: d79362f7e607ad6aaaeea79261096d71

 * Calendar *
Date format: DD/MM/YYYY
Time format: HH24:MI:SS
Datetime format: HH24:MI:SS.FF DD/MM/YYYY
Timestamp format: HH24:MI:SS DD/MM/YYYY

Abbreviated month names:
1. ១
2. ២
3. ៣
4. ៤
5. ៥
6. ៦
7. ៧
8. ៨
9. ៩
10. ១០
11. ១១
12. ១២

Abbreviated month names, sorted for tokenizer:
1. ៩ = month 9
2. ៨ = month 8
3. ៧ = month 7
4. ៦ = month 6
5. ៥ = month 5
6. ៤ = month 4
7. ៣ = month 3
8. ២ = month 2
9. ១២ = month 12
10. ១១ = month 11
11. ១០ = month 10
12. ១ = month 1

Wide month names:
1. មករា
2. កុម្ភៈ
3. មិនា
4. មេសា
5. ឧសភា
6. មិថុនា
7. កក្កដា
8. សីហា
9. កញ្ញា
10. តុលា
11. វិច្ឆិកា
12. ធ្នូ

Wide month names, sorted for tokenizer:
1. ឧសភា = month 5
2. សីហា = month 8
3. វិច្ឆិកា = month 11
4. មេសា = month 4
5. មិនា = month 3
6. មិថុនា = month 6
7. មករា = month 1
8. ធ្នូ = month 12
9. តុលា = month 10
10. កុម្ភៈ = month 2
11. កញ្ញា = month 9
12. កក្កដា = month 7

Abbreviated weekday names:
1. អា
2. ច
3. អ
4. ពុ
5. ព្រ
6. សុ
7. ស

Abbreviated weekday names, sorted for parse order:
1. អា = weekday 1
2. អ = weekday 3
3. សុ = weekday 6
4. ស = weekday 7
5. ព្រ = weekday 5
6. ពុ = weekday 4
7. ច = weekday 2

Wide weekday names:
1. ថ្ងៃអាទិត្យ
2. ​ថ្ងៃច័ន្ទ
3. ថ្ងៃអង្គារ
4. ថ្ងៃពុធ
5. ថ្ងៃព្រហស្បតិ៍
6. ថ្ងៃសុក្រ
7. ថ្ងៃសៅរ៍

Wide weekday names, sorted for tokenizer:
1. ​ថ្ងៃច័ន្ទ = weekday 2
2. ថ្ងៃអាទិត្យ = weekday 1
3. ថ្ងៃអង្គារ = weekday 3
4. ថ្ងៃសៅរ៍ = weekday 7
5. ថ្ងៃសុក្រ = weekday 6
6. ថ្ងៃព្រហស្បតិ៍ = weekday 5
7. ថ្ងៃពុធ = weekday 4

Day periods:
1. ព្រឹក
2. ល្ងាច
3. ព្រឹក
4. ល្ងាច
5. ព្រឹក
6. ល្ងាច
7. ព្រឹក
8. ល្ងាច
9. ព្រឹក
10. ល្ងាច
11. ព្រឹក
12. ល្ងាច

Day periods, sorted for tokenizer:
1. ល្ងាច = day period 2
2. ល្ងាច = day period 4
3. ល្ងាច = day period 6
4. ល្ងាច = day period 8
5. ល្ងាច = day period 10
6. ល្ងាច = day period 12
7. ព្រឹក = day period 1
8. ព្រឹក = day period 3
9. ព្រឹក = day period 5
10. ព្រឹក = day period 7
11. ព្រឹក = day period 9
12. ព្រឹក = day period 11

To test with a real database, let's create one:

# cd /opt/cubrid/databases/
# mkdir demodb
# cd demodb
# cubrid createdb demodb
បងើ្កតទិន្នន័យដែលមានទំហំ 512.0M. ទំហំថាសដែលត្រូវការស្មើនឹង1.5G.

CUBRID 9.1

We can notice that the database is successfully created and the messages are now displayed in Cambodian language.

Now let's start the newly created database.

# cubrid server start demodb
@ cubrid server start: demodb

This may take a long time depending on the amount of recovery works to do.

CUBRID 9.1

++ cubrid server start: success

Just for a reference, here is a Khmer Unicode table PDF.

Let's create a table and insert something using CUBRID's CSQL command line client program.

# csql demodb

អ្នកបកស្រាយCUBRID SQL


ប្រភេទ `;help' សម្រាប់សារជំនួយ (help messages)។

csql> SHOW TABLES;

=== <Result of SELECT Command in Line 1> ===

ពុំមានលទ្ធផលសោះ។

0 row selected.
SQL statement execution time:     0.169970 sec

កិច្ចសម្រួលដំណើរការបច្ចុប្បន្ន ត្រូវបានប្រតិបត្តិ។

1 command(s)បានដំណើរការដោយជោគជ័យ។
csql> CREATE TABLE tbl_animals (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(20) UNIQUE);
SQL statement execution time:     0.019585 sec

កិច្ចសម្រួលដំណើរការបច្ចុប្បន្ន ត្រូវបានប្រតិបត្តិ។

1 command(s)បានដំណើរការដោយជោគជ័យ។
csql> SHOW TABLES;

=== <Result of SELECT Command in Line 1> ===

  Tables_in_demodb    
======================
  'tbl_animals'       


1 row selected.
SQL statement execution time:     0.013054 sec

កិច្ចសម្រួលដំណើរការបច្ចុប្បន្ន ត្រូវបានប្រតិបត្តិ។

1 command(s)បានដំណើរការដោយជោគជ័យ។
csql> INSERT INTO tbl_animals ([name]) VALUES ('ឆ្កែ'), ('ដំរី');

2 rows affected.
SQL statement execution time:     0.005515 sec

កិច្ចសម្រួលដំណើរការបច្ចុប្បន្ន ត្រូវបានប្រតិបត្តិ។

1 command(s)បានដំណើរការដោយជោគជ័យ។

csql> SELECT * FROM tbl_animals;

=== <Result of SELECT Command in Line 1> ===

           id  name                
===================================
            1  'ឆ្កែ'      
            2  'ដំរី'      


2 rows selected.
SQL statement execution time:     0.010480 sec

កិច្ចសម្រួលដំណើរការបច្ចុប្បន្ន ត្រូវបានប្រតិបត្តិ។

1 command(s)បានដំណើរការដោយជោគជ័យ។
csql> SELECT * FROM tbl_animals WHERE [name] LIKE '%ែ%';

=== <Result of SELECT Command in Line 1> ===

           id  name                
===================================
            1  'ឆ្កែ'                 


1 row selected.
SQL statement execution time:     0.006739 sec

កិច្ចសម្រួលដំណើរការបច្ចុប្បន្ន ត្រូវបានប្រតិបត្តិ។

1 command(s)បានដំណើរការដោយជោគជ័យ។
csql> ;ex

Everything is working. Though CSQL is not an ADO.NET program, but the logic is same. In ADO.NET program use UTF-8 encoding when establishing a connection with CUBRID. This will force all communications be Unicode compatible. Once these Unicode data is transfere to CUBRID, CUBRID Server will know how to handle them.

Similarly, when querying the data in Khmer Unicode character set, use UTF-8 in your application.

If you have other questions, feel free to ask. We will be glad to help you!

link comment (0)
answered 10 months ago
admin
86
0

Thanks alot for your answer on how to config Cubrid to support Khmer Unicode on Linux Server.

I need your help again on How to config Cubrid on Windows Server 64 bit to support Khmer Unicode.

Best Regards.

Phath.

link comment (0)
answered 10 months ago
phath
6
tagged




You are either using a very old browser or a browser that is not supported.
In order to browse cubrid.org you need to have one of the following browsers:



Internet Explorer: Mozilla Firefox: Google Chrome: