CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Query Contacts with UTF-8 special characters
Pages: [1]

Author Topic: Query Contacts with UTF-8 special characters  (Read 566 times)

pederb

  • I’m new here
  • *
  • Posts: 27
  • Karma: 0
  • CiviCRM version: 4.3.5
  • CMS version: Drupal 7.22
  • MySQL version: MySql 5.1
  • PHP version: 5.3
Query Contacts with UTF-8 special characters
June 19, 2013, 06:56:42 am
Why can't CiviCRM API find Contact records when searchvalue contains special characters as Ä..?
Everything works fine with "normal" characters.

Code:
...
$params['last_name'] = 'Ägir';
$res = civicrm_api('contact','Get',$params);

Searchvalue is UTF-8, read from UTF-8 file with parsecsv.
Sourcecode files are UTF-8 with BOM.
Database and tables are utf8_unicode_ci.

pederb

  • I’m new here
  • *
  • Posts: 27
  • Karma: 0
  • CiviCRM version: 4.3.5
  • CMS version: Drupal 7.22
  • MySQL version: MySql 5.1
  • PHP version: 5.3
Re: Query Contacts with UTF-8 special characters
June 20, 2013, 07:04:05 am
I debugged and found out that the error relates to the fact that string-values are converted to lowercase when building the SQL where clause.

In the function buildClause in CRM_Contact_BAO_Query we have the following code:

        if ($dataType == 'String') {
          $value = "'" . strtolower($value) . "'";
        }

Shouldn't this be mb_strtolower...?
I have tried to change it and it works.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Query Contacts with UTF-8 special characters

This forum was archived on 2017-11-26.