When I try to create an account based on the username, from LDAP/AD, in Drupal, I also want to retrieve some important information such as name of the person, department, job title, telephone, etc. The issue is that when I retrieve the department or job title, sometimes the information isn't saved in the Drupal user profile. I realized that it was probably because some job titles are named "Human Resources", where as others are named "Assistant Eng/Officer | Solutions". The "|" would be a special character, at least from my understanding and mySQL experience. How would I go about validating the entry and possibly stripping it of the 'invalid' characters so that it shows up in the profile? Any help would be appreciated.

Zee

Comments

syedz’s picture

Thanks, but unfortunately I've already tried that and it doesn't seem to work.

syedz’s picture

Okay so after doing some research I found out that it isn't the "|" that's an invalid character. The "|" is actually an Em dash in the ASCII table. I can't seem to find anything that works including htmlspecialchars(), urlencode(), and a few others. I'm left with having to create a function that looks for special characters using numerous str_replace()'s. There has to be a more efficient way of doing this, anyone with any advice is welcome to suggestions.
Thanks,

Zee