ttacon / libphonenumber

golang port of Google's libphonenumber
MIT License
618 stars 105 forks source link

Bugfix: Encoding of country code in FormatOutOfCountryCallingNumber #54

Open jojomi opened 7 years ago

jojomi commented 7 years ago

Minimal testcase:

phonenumber, err := libphonenumber.Parse("+3587884512974", "DE")
fmt.Println(libphonenumber.FormatOutOfCountryCallingNumber(phonenumber,
"DE"))

This change is Reviewable

ttacon commented 7 years ago

Hi! Thanks for the PR! A few questions:

1) Can you add a test to the test code to show what you're trying to fix here as well (I know that it's in the comment above but if it's a test case we're fixing it should also go into the unit tests)?

2) What exactly is the issue that you're trying to resolve? I'd prefer not to incur multiple allocations to do an integer -> []byte conversion.

Thanks!

jojomi commented 7 years ago

Thank you for having a look.

  1. I can try, but currently my time is limited. I am okay with leaving this PR open until added
  2. Is there a quicker way to get from an int to []byte? The point is that the bit wizardry seems wrong there, the country code integer just needs to be printed. The current code yields seemingly random (non-numerical) characters depending on what character codes are mapped after shifting around.