Closed shriek1 closed 1 month ago
The library doesn’t consider -
as a separator for an extension number as it’s also a formatting separator for other formats (US for example which is (111) 222-3333
) so the number 0234/123456-10
is parsing as 023412345610
with the extension number being appended.
I’ll have to do some thinking about how to cater for this.
The most reliable option for you is trimming the extension number based upon the presence of the -
before calling PhoneNumber.Parse(string)
.
The most reliable option for you is trimming the extension number based upon the presence of the
-
before callingPhoneNumber.Parse(string)
.
Yes. That might be one way to handle it. However most user input is expected to be without any seperators between the numbers. Some numbers have an extension and you wouldn't even know about it until you saw more numbers to the same base number.
Germany has variable subscriber number lengths for some area codes so you’re going to really struggle if there isn’t even a separator in the input.
Comig back to this i've found the following. https://www.bundesnetzagentur.de/DE/Fachthemen/Telekommunikation/Nummerierung/ONRufnr/Laenge/L%C3%A4nge_ONRufnr_Basepage.html Which says that numbers can be 11 digits long and the recommondation is to stay below 13 digits in general. The site also provides a list for all the area codes and the number of digits. But looks like most have 11 digits. Sadly the information doesn't seem to be available in english, even looked around there but couldn't find it.
This is the latest German numbering plan, published to the ITU and this is what I’ve used to build the data file for the library. You’ll notice that most geographic numbers have a min national significant number length of 6 and max of 11. Whilst only 10 or 11 digit numbers have been assigned since 2011, I suspect any assigned prior retain shorter lengths.
@shriek1 good news, I’ve implemented a solution that seems to work, I have a bit more testing to do but if all goes to plan I’ll release 3.5.6 shortly with the implementation.
@TrevorPilley Nice, thank you! Didn't see this until today. Will update and see if it's working better now.
First of, my goal is not to figure out which part of a phone number is the extension. That would probably require more of an index of valid phone numbers and figure out which digits would be the extension based of off that.
I have, for example a phone number like this: 0234/123456-10 That works without any problems, finds the area code etc. However if you add one more digit to it, which is also a valid number it's no longer possible to parse the number. E.g. "0234/123456-106" will not work even if it's a valid phone number.
My requirement is to be able to just enter the number as is and validate it. The only solution i could currently think of for my scenario would be to cut of the last digit and see if that turns out to be a valid number and after that just add all the removed numbers back.
BTW, as for entering a number with an extension or printing it the common way for german numbers is to use a minus sign in between the number and the extension. So it would look like this 012345/987654-0.