0

I have a PDF form that submits data into a mysql database with php.

Problem is i want to remove diacritics from all fields (before the data reaches the php script) when i press the submit button. For example i have in the PDF form a field that contains "ă" and in another one "î". When i press the submit button i need a javascript to do the conversion to "a" and "i" before posting data to php...this should all happen inside the PDF form.

I have tryied to replace the chars in php submit script with str_replace, but it is too late to do that since the chars are already compromised from the PDF output.

Any ideas?

Cilonx
  • 33
  • 6
  • Wouldn't it make much more sense to fix the real cause of the issue instead of fingering around with the symptom? You want to keep the data as it is usually. You "just" have to fix your setup such that _all_ components are able to work with that. – arkascha Sep 22 '16 at 08:56
  • http://stackoverflow.com/questions/279170/utf-8-all-the-way-through – arkascha Sep 22 '16 at 08:56
  • pdf forms do not work as normal html forms, data migration from pdf is more complicated than about setting up the database to accept diacritics....ie. those diacritics from my initial post are represented both with "." on pdf output....pdf doesnt know how to code them. – Cilonx Sep 22 '16 at 09:15
  • The PDF format certainly does not pose any restriction on what character sets you can use on you. If the rendering software you use to display a PDF document has issues to do so, then check your character encoding. – arkascha Sep 22 '16 at 09:17

1 Answers1

0

Check that the character encoding on your PDF/PHP side is the same as the MySQL side, for example ensure they are both UTF-8.

Or if you wanted to perform a quick fix with Javascript this would work.

var message = "hello this is ă test"; 
var character = "ă"; 
var replaceWith = "a"; 

var new_text = message.replace(character,replaceWith);

console.log(new_text);
davesherlock
  • 185
  • 1
  • 1
  • 9
  • The replace would work on [U+0103](http://graphemica.com/%C4%83), but that character can also consist of two code points (`a` and a [combining breve](http://graphemica.com/0306)). Best to use proper tools for this. – robertklep Sep 22 '16 at 09:41