A
A
alexeu2014-07-13 14:25:26
MySQL
alexeu, 2014-07-13 14:25:26

Why are question marks displayed instead of Russian letters, data from mysql via odbc?

The situation is as follows, in the dialplan I want to display data in Russian from the mysql database via odbc.
Asterisk 1.8.12.2 on debian 6, mysql 5.5.35-0+wheezy1 encoding UTF-8 Unicode (utf8). The database from which I pull the data comparison with utf8_general_ci, the table has a similar encoding. Debian also has utf8 installed.
There are no problems with the settings:
/etc/odbc.ini:

[asterisk-connector]
Driver = MySQL
Description = Connector/ODBC 3.51 Driver DSN
Server = localhost
Port = 3306
User = asterisk
Password = ********
Database = asterisk
Socket = /var/run/mysqld/mysqld.sock

/etc/asterisk/res_odbc.conf:
[asterisk]
enabled = yes
dsn = asterisk-connector
username = asterisk
password = *******
pooling = no
limit = 1
pre-connect = yes

The function itself in /etc/asterisk/func_odbc.conf:
[NAME]
dsn=asterisk
readsql=select name from destinations where prefix in (substr('${CALLERID(num)}',2,7),substr('${CALLERID(num)}',2,6),substr('${CALLERID(num)}',2,5),substr('${CALLERID(num)}',2,4),substr('${CALLERID(num)}',2,3)) order by length(prefix) DESC limit 1

When using the function in the dialplan:
exten => 84959898533,1,Set(CALLERID(name)=${ODBC_CODE()})

Question marks appear instead of the Russian word. English tex issues correctly.
I decided that this problem goes to the server bundles, asterisk. I tried to solve.
The most interesting thing is that on this server there was a site in Russian, as I uploaded it to the server instead of Russian, there were also question marks. I solved this problem by suppressing the following lines in the php code for connecting to the mysql database:
mysqli_query($db_ad, "SET NAMES 'utf8' COLLATE 'utf8_general_ci'");
mysqli_query($db_ad, "SET CHARACTER SET 'utf8'");

Naturally, this time to dig in this direction.
As a result of a Google search, I added the following lines to the /etc/mysql/my.cnf file:
[mysqld]
init-connect="SET NAMES utf8"
character-set-server=utf8
collation-server=utf8_general_ci

After that, the site in Russian began to be displayed without question marks (the base of the site and the one that I am trying to use in the same encodings described above), even with completed lines for setting up the encoding.
Now on the server by encodings, after editing the mysql settings, I have the following picture:
mysql> show variables like 'char%';
+--------------------------+----------------------------+
| Variable_name            | Value                      |
+--------------------------+----------------------------+
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | utf8                       |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | utf8                       |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
+--------------------------+----------------------------+

But the text from the database on odbc still goes with question marks.
[email protected]:~# locale
LANG=ru_RU.UTF-8
LANGUAGE=
LC_CTYPE="ru_RU.UTF-8"
LC_NUMERIC="ru_RU.UTF-8"
LC_TIME="ru_RU.UTF-8"
LC_COLLATE="ru_RU.UTF-8"
LC_MONETARY="ru_RU.UTF-8"
LC_MESSAGES="ru_RU.UTF-8"
LC_PAPER="ru_RU.UTF-8"
LC_NAME="ru_RU.UTF-8"
LC_ADDRESS="ru_RU.UTF-8"
LC_TELEPHONE="ru_RU.UTF-8"
LC_MEASUREMENT="ru_RU.UTF-8"
LC_IDENTIFICATION="ru_RU.UTF-8"
LC_ALL=

In /etc/locale.gen file:
en_US.UTF-8 UTF-8
ru_RU.UTF-8 UTF-8

/etc/asterisk/extensions.conf:
exten => _7XXXXXXXXXX,n,Set(CALLERID(name)=${ODBC_NAME()})
exten => _7XXXXXXXXXX,n,jabbersend(asterisk,******@jabber.ru, Звонок от ${CALLERID(name)})

Question marks appear in the Asteriks console and in jabber:
Executing [7**********@incoming-youmagic:7] Set("SIP/youmagic-00000004", "CALLERID(name)=??? 6422") in new stack
    -- Executing [7*********@incoming-youmagic:8] JabberSend("SIP/youmagic-00000004", "asterisk,*****@jabber.ru, Звонок от ??? 6422 с номера  <+7*********> в 15:08:39 2014-07-13 ") in new stack

Accordingly, "CALLERID(name)=??? 6422" should be "CALLERID(name)=Olya 6422"
I'll never know what to do, I've already tried everything. I ask for your help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2014-07-13
@alekseu

and what for there odbts?
upd:
lists.digium.com/pipermail/asterisk-users/2012-Dec...
/etc/odbc.ini

[MySQL-asterisk]
Description = MySQL ODBC Driver
Driver = MySQL
Socket = /var/run/mysqld/mysqld.sock
Server = localhost
User = my_username
Password = my_password
Database = my_database
Option = 3
Port =
Charset = utf8

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question