Skip to content
September 19, 2011 / Samer Baydoun

Why Trim function saves money

The answer simply: because it saves developer’s time.

In one of the php/Mysql websites I faced a problem with the sort order of some multilingual data. Usually when someone sort order such column, they get the English text first then the other languages like Arabic:

English text 1

English text 2

نص عربي 1

نص عربي 2

But what I have got was something like:

نص عربي 2

English text 2

English text 1

نص عربي 1

Actually some previous transportation processes of the database as well the high distortion of the sorted data made me thought that I have an encoding problem.

After 3 hours of work, trying to check the original encoding of data, I suddenly found that the web admin enters white spaces at the beginning of the entry very frequently. Although this made me smiling, as it saved me from falling in the hell of double-encoding problems, it pushed me to put a new ‘Must’ on my programming practices rules list.

The rule is the use of trim() function wherever the user has to enter data.

Advertisements

One Comment

Leave a Comment
  1. Enunk / Feb 2 2012 7:18 pm

    hi??

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: