Microformats testsuite

Microformats phone number formats

Introduction

Although phone numbers are considered to be a string value in the Microformats specifications, some parsers do treat them as a data type and perform different levels of validation. To allow the test-runner to test parsers equally the following method canonicalise and compare phone numbers.

Canonicalise phone number

This code takes a string phone number and provides a canonicalised version.

Compare

This code takes the two phone numbers and compares canonicalised version of them to see if they are equal.

Examples of phone number canonicalisation

01273 715100                  01273715100
+44 1273 715100               +441273715100
800-555-1212                  8005551212
800.555.1212                  8005551212
(800) 555-1212                8005551212
800-555-1212x1234             80055512121234
800-555-1212 ext. 1234        80055512121234 
work 1-(800) 555.1212 #1234   180055512121234 

 

Some rights reserved