Still, I strongly disagree that there is a standard string representation for phone numbers.
For example, French phone numbers don't have area codes (since 2022), and they are typically (but not always!) displayed as 0X XX XX XX.
For example, French phone numbers don't have area codes (since 2022), and they are typically (but not always!) displayed as 0X XX XX XX.
Comments
But I guess this is kinda like date/time. toString isn't required to return a consistent representation. Something "good enough" will do for messy data, but the underlying data structure must be quite flexible (e.g. a string or integer in this case).
Admittedly, I didn't know much of this, but “five pairs of digits” is how all phone numbers are displayed, except some companies that take shortcuts
If you need to actually render a phone number for a user, you probably want something separate like a formatter class.
I still wouldn't call this the standard formatting though.
The way Brazilian phone numbers are displayed is different, so that would never be an instant match for me.