Michael,
The C# format codes are derived from Microsoft Excel.
Number format codes
http://office.microsoft.com/en-us/excel-help/number-format-codes-HP005198679.aspxCreate a custom number format
http://office.microsoft.com/en-us/excel-help/create-a-custom-number-format-HP010342372.aspxExcel has a special conditional format code for phone numbers.
Excel 2010
Format Cells
Locale: English (U.S.)
Category: Special
Type: Phone Number
Format Code: [<=9999999]###-####;(###) ###-####
As you can see, 1234567, which is <=9999999, is 123-4567 and 1234567890, which is not <=9999999, is (123) 456-7890, which follows the ITU-T standard.
ITU-T
TELECOMMUNICATION
STANDARDIZATION SECTOR
OF ITU
Notation for national and international
telephone numbers, e-mail addresses and
Web addresses
E.123 (02/2001)
7 Procedural symbols
A procedural symbol is a symbol which tells the subscriber how to dial. Such symbols should not appear in a finger hole or on a push button because they are not to be dialled.
7.2 Use of parentheses
The symbol ( ) (parentheses) should be used to indicate that the digits within the ( ) are not always dialled.
The ( ) should enclose:
• the trunk prefix and trunk code in a national number;
• the trunk code when the trunk prefix is not in universal use within a country.
This is done to remind the user not to dial the enclosed digits for calls within the same numbering area.
The ( ) should not be used in an international number.
T-REC-E.123-200102-I!!PDF-E.pdf
http://www.itu.int/rec/T-REC-E.123-200102-I/enPeter
On Wednesday, June 5, 2013 7:32:39 PM UTC-4, Michael Jones wrote:
I'm curious what should happen in that format with short (7-digit) numbers.
I think 123-4567 makes sense, but "() 123-4567" or "( ) 123-4567" do not. Does the C# formatting library drop the parentheses on the left when there are not enough digits?
The Go code somebody wrote for you does an explicit test, but I'm curious if the PICTURE-like specification has a rule like "fill in from right to left and when the digits run out, stop copying anything." I looked for this on the website but did not see it.