I need to preserve tab characters from a textarea through POST Data. It seems that there's no way to differentiate tabs from spaces in the $_POST array, and this is really frustrating me.
I'm using a jQuery plugin from here to allow for tab and shift+tab usage within a textarea. http://teddevito.com/demos/textarea.html
The jQuery plugin is using this as its Tab character:
$.fn.tabby.defaults = {tabString : String.fromCharCode(9)};
For some reason, it shows an individual space instead of each tab character, so all my code formatting is lost:
<textarea name="field0" rows="26" cols="123"><?php
echo $_POST['field0'];
?></textarea>
This also doesn't work. Apparently the tabs disappear before the data even reaches the str_replace function (the first double quotes is the result from when I press TAB in my text editor):
<textarea name="field0" rows="26" cols="123"><?php
echo str_replace(" ", "\t", $_POST['field0']);
?></textarea>
The reason I need tabs and not multiple spaces is because my application includes on-line code editor.
Anyone have any ideas? I'm guessing the solution would involve modifying the data with javascript before it's sent through POST, but I haven't the slightest idea how to start.