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) »
  • API Contact does not process special characters in the name
Pages: [1]

Author Topic: API Contact does not process special characters in the name  (Read 2543 times)

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
API Contact does not process special characters in the name
March 19, 2009, 07:00:22 am
Hi there, I am enjoying myself thoroughly with CiviCRM and the API´s  :) Before I start about my problem, let me state that I really think it is a wonderful product with good documentation and support!

So, with the contact API (function contact_add: it looks as if special characters are not processed. My values in params when I call the function are :
Array ( [first_name] => José [last_name] => Brinkman [middle_name] => [contact_type] => Individual [job_title] => [gender_id] => 1 [prefix_id] => [birth_date] => 19690904 [dupe_check] => true )

but when I look in CiviCRM I see the name as: Jos Brinkman, and this is also the value in the database. So it looks like the API is the problem, am I right? If so, I will raise an issue but it might well be there is a setting I have overlooked  ;D

Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

Kiran Jagtap

  • Ask me questions
  • ****
  • Posts: 533
  • Karma: 51
Re: API Contact does not process special characters in the name
March 19, 2009, 07:16:26 am
hi,

I have tried on my local install for v2.2 with
Code: [Select]
        $params = array( 'first_name' => 'José',
                         'last_name' => 'Brinkman',
                         'middle_name' => '',
                         'contact_type' => 'Individual',
                         'job_title' => '',
                         'gender_id' => 1,
                         'prefix_id' => '',
                         'birth_date' => '19690904',
                         'dupe_check' => true);
        require_once 'api/v2/Contact.php';
        $contact = civicrm_contact_add( $params );

my contact created with
first name = José
last name =  Brinkman

it seems to be working fine.

kiran
       
 
You Are Designed To Choose... Defined By Choice.

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: API Contact does not process special characters in the name
March 19, 2009, 08:45:35 am
Thanks for your reply Kiran.... so it probably is some kind of setting. I am not much wiser though when it works on your machine  ;)
Any helpful hints?
Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

pst_manly

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: 6.19
  • MySQL version: 5.0.45
  • PHP version: 5.2.13
Re: API Contact does not process special characters in the name
January 15, 2011, 02:08:15 am
*bump*

I understand that this topic is really old.

But I sure do encounter this and it still doesn't work on me too.

Any hint on how to allow special characters in API?

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: API Contact does not process special characters in the name
January 15, 2011, 02:35:04 am
Are you sure your strings are utf8 encoded?

To avoid any issue in the future, I would suggest you to add a test that cover your need case
http://wiki.civicrm.org/confluence/display/CRM/Setting+up+your+personal+testing+sandbox+HOWTO
and
http://wiki.civicrm.org/confluence/display/CRM/CiviCRM+Unit+Testing+basic+information
(probably as easy to go to the existing file see what is done and add your test)

http://svn.civicrm.org/civicrm/trunk/tests/phpunit/api/v2/ContactTest.php

Quote from: pst_manly on January 15, 2011, 02:08:15 am
But I sure do encounter this and it still doesn't work on me too.

Any hint on how to allow special characters in API?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

pst_manly

  • I’m new here
  • *
  • Posts: 19
  • Karma: 0
  • CiviCRM version: 3.3
  • CMS version: 6.19
  • MySQL version: 5.0.45
  • PHP version: 5.2.13
Re: API Contact does not process special characters in the name
January 15, 2011, 03:05:59 am
Quote from: xavier on January 15, 2011, 02:35:04 am
Are you sure your strings are utf8 encoded?

To avoid any issue in the future, I would suggest you to add a test that cover your need case
http://wiki.civicrm.org/confluence/display/CRM/Setting+up+your+personal+testing+sandbox+HOWTO
and
http://wiki.civicrm.org/confluence/display/CRM/CiviCRM+Unit+Testing+basic+information
(probably as easy to go to the existing file see what is done and add your test)

http://svn.civicrm.org/civicrm/trunk/tests/phpunit/api/v2/ContactTest.php

Quote from: pst_manly on January 15, 2011, 02:08:15 am
But I sure do encounter this and it still doesn't work on me too.

Any hint on how to allow special characters in API?

I am sure the string is utf8 encoded.

On other note, I don't have problems the provided tests. It's just that I tried some special character data and it doesn't work.

For easy testing, I only tried Kiran Jagtap's posted sample. which fails on me.

-----

Anyway, special chars did work when doing submission through website's form. I think I'll just trace it from there.

Thanks
« Last Edit: January 15, 2011, 03:31:53 am by pst_manly »

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • API Contact does not process special characters in the name

This forum was archived on 2017-11-26.