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 (Moderator: Donald Lobo) »
  • Lenght create contact special chars
Pages: [1]

Author Topic: Lenght create contact special chars  (Read 381 times)

rubofvil

  • I’m new here
  • *
  • Posts: 23
  • Karma: 1
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 7
  • MySQL version: mysql 5.1
  • PHP version: php 5.2
Lenght create contact special chars
October 22, 2013, 05:35:40 am
I'm trying to import some contacts with API,
When i create the contact with the contact form(civicrm/contact/add?reset=1&ct=Individual) is not problem.
But when I create the same contact with the API, the validation give me a problem with maxlength .
I think that the Greek chars are counted two times.

Example with this First name: "ΚΑΙΑΣΚΕΥΑΣΤΩΝ ΝΙΚΑΙΑΣ-ΚΟΡΥΔ-ΠΚΟΡΥΠΚ" (35 chars)
"error_message":"Value for first_name is 67 characters  - This field has a maxlength of 64 characters.",

Any possible solution? Thanks!

rubofvil

  • I’m new here
  • *
  • Posts: 23
  • Karma: 1
  • CiviCRM version: 4.2.7
  • CMS version: Drupal 7
  • MySQL version: mysql 5.1
  • PHP version: php 5.2
Re: Lenght create contact special chars
October 22, 2013, 06:56:20 am
I change in file civicrm/api/v3/utils.php

In line 1548(version 4.3.7)

Code: [Select]
elseif (is_string($value) && !empty($fieldInfo['maxlength']) && strlen($value) > $fieldInfo['maxlength']) {
Code: [Select]
  elseif (is_string($value) && !empty($fieldInfo['maxlength']) && mb_strlen($value) > $fieldInfo['maxlength']) {
I hope that this change not be critical. ???

Luciano S.

  • I post occasionally
  • **
  • Posts: 83
  • Karma: 2
  • iXiam Team Leader
  • CiviCRM version: 4.2+ / 4.3+ / 4.4+
  • CMS version: Drupal
  • MySQL version: 5.1+ / 5.5+
  • PHP version: 5.3+ / 5.4+
Re: Lenght create contact special chars
October 22, 2013, 07:12:27 am
Hi, two ideas about this:

1. Be sure mbstring extension is enabled (not by default in PHP)
http://www.php.net/manual/en/mbstring.installation.php

2. Would be a good idea to pass the encodig paramater to mb_strlen() function. If not you are relying on server default encoding. For instance:
Code: [Select]
mb_strlen($str, "UTF-8");http://es1.php.net/manual/en/function.mb-strlen.php

cheers!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Lenght create contact special chars

This forum was archived on 2017-11-26.