Email address RFC

development, fun Comments Off on Email address RFC

It’s was entertaining to dig into email address format while working on a corresponding task.

Here are a few facts that I didn’t expect to be allowed for email address:

  • the local part of an email address can contain spaces, and it must be quoted and escaped by a back slash like “\ “
  • the local part of an email address can contain comments! It’s put in parentheses and can be omitted. Example: “john(comment)” equals to “
  • domain part can have IP instead of domain. To do that, it must be put in square braces like “john@[]”

Here are examples of VALID email addresses:

  • '@[]
  • user@[IPv6:2001:db8:1ff::a0b:dbd0]
  • "much.more\ unusual"
  • ""
  • "very.(),:;<>[]\".VERY.\"very@\\\ \"very\".unusual"
  • 0@a
  • !#$%&'*+-/=?^_`{}|
  • "()<>[]:;@,\\\"!#$%&'*+-/=?^_`{}|\ \ \ \ \ ~\ \ \ \ \ \ \ ?\ \ \ \ \ \ \ \ \ \ \ \ ^_`{}|~.a"
  • ""

Javascript: indexOf problem in empty array

development, jquery Comments Off on Javascript: indexOf problem in empty array

Funny, but indexOf method doesn’t work in an empty array in Internet Explorer, the method is just not defined. Eh!

Forget about that and always use jQuery wrapper –

$.inArray(42, [31, 42, 53]);

Delete Your Code #7: Right encoding

db, delete your code, development, encoding, mysql, php, server Comments Off on Delete Your Code #7: Right encoding

You might be surprised, but a right choise of the project text encoding can affect the project file size and amount of bugs.

To avoid bugs of wrong presentation of text on your page, make sure that all database entities and the application server (PHP) use the same encoding. That helps to forget about issues connected with text presentation.

On database side, make sure you set the correct encoding to:

  • database,
  • tables,
  • columns,
  • import-export tools parameters (a big source of wrong encoding bugs),
  • corresponding SQL server variables

On application server it’s usually just one query –


Pay attention, that utf8 might be not the best choise for your project: every non-English character needs 2-6 bytes of memory, so if you built a one-language (local) project with lots of database data, consider using a 1 byte encoding like windows-1251 and save about half of the space on server file system.

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in