Showing posts with label Arabic Programming. Show all posts
Showing posts with label Arabic Programming. Show all posts

Saturday, March 20, 2010

Tutorial: Validating User's Arabic Input using Regular Expressions in PHP

In PHP, Regular Expressions can be used to match a string to a specific pattern, this can be used to validate user's input to avoid certain security problems such as spoofed form submissions and cross-site scripting (see http://phpsec.org/projects/guide/), this can be done using preg_match() function

Here I'll talk only about using preg_match() to validate arabic input, for an explanation of regular expressions in PHP, see http://www.phpro.org/tutorials/Introduction-to-PHP-Regex.html

First Method you can use to make regular expressions include arabic is using \p{Arabic}, this makes preg_match() accept arabic strings,

that's not completely true :D

The previous paragraph is maybe what you would get if you searched the Internet for arabic patterns, but it needs following modifications to work correctly:

  • use /u modifier so the pattern will be treated as UTF-8 (you can make it for all your patterns since it works only for alphanumeric characters) >> '/\p{Arabic}/u'

  • use the HTML META tag so that Request parameters (GET & POST) will be encoded as unicode (the charset attribute should be UTF-8)

those two steps are important to make your validation work

another method is using arabic characters unicode codes, you can use /\x{****}/u to represent any unicode character, also /[\x{****}-\x{----}]/u makes the pattern support any character/symbol which its unicode lies between **** and ----, but do not forget the /u modifier and setting charset to UTF-8

Tuesday, March 4, 2008

لغة ج للبرمجة باللغة العربية

عنوان قد يكون مضحك لكم يا رفاق العمل .... أليس كذلك ؟

ربما للوهلة الأولى نعم أتفق معكم ..... قد يكون صعبا على من تفتحت عيناه على البرمجة فلم ير إلا لغات إنجليزية وعلى حد علمى كلها كذلك حتى الآن

ولكنها فكرة جيدة بلا شك من وجهة نظرى محاولة تعريب لغة البرمجة

قرأت عن لغة ج منذ فترة ليست بالقصيرة لكنى فشلت فى استخدامها ثلاث مرات على ما أذكر بسبب مشاكل فى اللغة فى ويندوز إكس بى

واليوم هى أول مرة أنفذ على جهازى المتواضع برنامج مكتوب بلغة برمجة عربية !!!! ولم أتصور أنى سأفعل يوما ما

دعنا نرى الأمر من زاوية اخرى غير الضحك والتهكم

دعنا ننظر إليها كمحاولة مبدأية قد يكتب لها النجاح أو الفشل وقد تحتاج إلى سنوات وسنوات من العمل والتعديل والابتكار والإبداع و.... إلخ

ولكن من طلب منا أن نفنى أعمارنا فيها .... دعنا نلقى عليها نظرة ... ومن يكمنه المشاركة فليشارك ... ومن يقتنع بالفكرة فليمض

من قال أن العالم أعجمى أبد الدهر .... ربما يجتاج بناء نظم حاسب مماثلة أو قريبة من تلك فى العالم المتقدم إلى 1000 أو 2000 سنة

فإذا بدأنا الآن وكل وضع القليل سنصل بعد 2000 سنة وإذا لم نيدأ لن نصل أبداً

على أى الاحوال أنا غير مسموح لى التحدث فى شئ ليس له علاقة بالحاسب ومجالاته المختلفة هنا لأنى أنوى نشره على مدونة القسم إن شاء الله

وأرجوا المعذرة فى أخطأ اللغة العربية فأنا للأسف لست من الأقوياء فيها

دى روابط اللغة
الصفحة الرئيسية
http://www.jeemlang.com/index.php
كتاب التعريف
http://www.jeemlang.com/documentation/webframe.html

ده البرنامج اللى أنا شغلته النهاردة

! برنامج لحساب مضروب عدد صحيح

المتحول ن : صحيح

المتحول ص ، ع : صحيح

أجعل ع = 1

أكتب "أدخل عدداً صحيحاً لتعرف قيمة مضروبه :" ، سطر

أقرأ ن

أجعل ص = ن

أكرر طالما ص > 1

{

أجعل ع = ع × ص

أجعل ص = ص - 1

}

أكتب ن ، "! =" ، ع