Closed mrclauss closed 2 years ago
To be honest I think it's quite confusing too, the naming and doc could be more clear on the fact that the isocode is the origin of the phone number.
So this is an international phone number located in germany and you are using IsoCode.US.
When using fromIsoCode, it will assume the phone number is from that part of the world, ence why the phone number result you get is "+1...".
You could try parseRaw
but that's less precise... Admittedly I don't think this feature is already in the library but would be a nice to have and it seems like the building blocks are already there.
You can have a look at this file if you are interested to implement it:
https://github.com/cedvdb/phone_numbers_parser/blob/dev/lib/src/parsers/phone_parser.dart
Sure, I'll try to implement it as time allows :) I'll raise a pull request once ready ...
Am 23. Juli 2022 13:00:28 MESZ schrieb cedvdb @.***>:
So this is an international phone number located in germany and you are using IsoCode.US.
To be honest I think it's quite confusing too because I had to take a look to the source since it's been quite some time I've looked at it.
When using fromIsoCode, it will assume the phone number is from that part of the world, ence why the phone number result you get is "+1...".
You could try
parseRaw
but that's less precise... Admittedly I don't think this feature is already in the library but would be a nice to have and it seems like the building blocks are already there.You can have a look at this file if you are interested to implement it:
https://github.com/cedvdb/phone_numbers_parser/blob/dev/lib/src/parsers/phone_parser.dart
-- Reply to this email directly or view it on GitHub: https://github.com/cedvdb/phone_numbers_parser/issues/26#issuecomment-1193106379 You are receiving this because you authored the thread.
Message ID: @.***>
-- Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.
Hi,
if I try to convert a US international call number to E164 using fromIso the country code is in my opinion not checked correctly in PhoneParser: Expected: PhoneNumber.fromIsoCode(IsoCode.US,"01149301234567").international == "+49301234567" Result: "+101149301234567" In contrast to the comment in line 74 phone_parser.dart the check does not check if any country code followed the international prefix but only checks if the given IsoCode prefix followed. ("if a country code did not immediately follow the international prefix") (E.g. parsing any non-german number with fromIsoCode(IsoCode.DE,"00....") also does not work).
Or maybe I used the wrong function, but I would assume if I have a "national" international number I need to parse it with PhoneNumber.fromIsoCode, specififying the originating country?
Cheers, Martin