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 weird characters
Pages: [1]

Author Topic: API weird characters  (Read 1807 times)

wexzone

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 0
API weird characters
February 24, 2011, 12:45:04 pm
I am getting some really weird characters around some of my content.  The content is from some custom fields.  The custom fields are check boxes, and the check box data is the only one with the strange characters.

The character is like a small white box with binary in it 0001.  CiviCRM is outputting these characters, they are not contained in the fields values.

Anyone see this before?  What's the fix?

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: API weird characters
February 24, 2011, 02:12:06 pm
It's the multivalue separator character used by civi.

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 weird characters
February 24, 2011, 02:54:07 pm
Hi,

Well spotted.

The fix would be to split these custom fields with multiple value on 0001 and return it as array. Want to give it a go ?
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

wexzone

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 0
Re: API weird characters
February 24, 2011, 04:33:53 pm
Is there a way to trim out that character?  Or do I need to treat these as an array, and split them?

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 weird characters
February 25, 2011, 12:23:49 am
Quote from: wexzone on February 24, 2011, 04:33:53 pm
Is there a way to trim out that character?  Or do I need to treat these as an array, and split them?

Yes, that's the way of storing a multivalue field into a single column. You'd need to split on that char. It would be awesome if you find a way of doing it in the API so we get it working out of the box directly.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: API weird characters
February 25, 2011, 03:11:00 am
Xavier/ wexone - I can't fish it out right now but there is a core function that does this - I think it may involve the word separator (mispelled from memory)
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

wexzone

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 0
Re: API weird characters
February 25, 2011, 06:52:22 pm
"word separator"?  Hmm, that sounds interesting.  I will try treating it as an array and split using php, and see if that works for now.  I can then research the multivalue character using the API.  I am sure there is a way to make it work.  I am also sure that I am not the first person to have this issue.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: API weird characters
February 25, 2011, 07:27:54 pm

check:

CRM/Core/BAO/CustomOption.php, function getOptionLabel

u should be able to retrieve the labels given the value (and fieldID)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

wexzone

  • I post occasionally
  • **
  • Posts: 33
  • Karma: 0
Re: API weird characters
March 01, 2011, 10:25:31 am
How would I actually split according the that character?  What is that character?

@lobo - I can't seem to find CustomOption, is that v3?  Could you get me started with a simple snippet?

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: API weird characters
March 01, 2011, 12:28:46 pm

check the file:

CRM/Core/BAO/CustomGroup.php

and search for that function to see how it is being used.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

Eileen

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4195
  • Karma: 218
    • Fuzion
Re: API weird characters
March 01, 2011, 12:32:01 pm
the functions in http://forum.civicrm.org/index.php/topic,18567.0.html are my GET functions for the option groups & option values tables. I haven't created them as an API because we'd need a test for them
Make today the day you step up to support CiviCRM and all the amazing organisations that are using it to improve our world - http://civicrm.org/contribute

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 weird characters
March 01, 2011, 01:32:45 pm
@wexzone

Obviously, your contribution is more than welcome and it would be greatly appreciated if you could put Eileen's function and a unit test for it.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • API weird characters

This forum was archived on 2017-11-26.