Skip to content

[1.7][maxmind] fix provider encondig. Force utf8. #268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

makasim
Copy link
Contributor

@makasim makasim commented Oct 15, 2013

No description provided.

@Baachi
Copy link
Member

Baachi commented Oct 15, 2013

Why not encode the whole file? This has some performance and memory issues.

@makasim
Copy link
Contributor Author

makasim commented Oct 15, 2013

@Baachi could explain how binary file could be encoded?

@Baachi
Copy link
Member

Baachi commented Oct 16, 2013

Hm this is a good question. I just google the problem and everyone suggest to use utf8_encode or mb_convert_encoding.

@makasim
Copy link
Contributor Author

makasim commented Oct 16, 2013

too many failed tests. I believe it is not me.

@Baachi
Copy link
Member

Baachi commented Oct 16, 2013

The tests didn't pass because the data from the differend providers has been changed.

@@ -83,6 +83,12 @@ public function getGeocodedData($address)
'latitude' => $geoIpRecord->latitude,
'longitude' => $geoIpRecord->longitude,
));

$results = array_map(function($value) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if it works, but i think array_walk_recursive('utf8_encode', $results) would work too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly saying I copy\pasted it from another Provider.

I dont think we need array_walk_recursive here as the array created few lines above and it contains scalars.

@makasim
Copy link
Contributor Author

makasim commented Oct 16, 2013

@willdurand any chance to merged it?

@willdurand
Copy link
Member

Do we really need this?

@makasim
Copy link
Contributor Author

makasim commented Oct 16, 2013

@willdurand just comment the fix and see how the test would fail

@willdurand
Copy link
Member

But the lib should not alter the encoding...

@makasim
Copy link
Contributor Author

makasim commented Oct 16, 2013

But the lib should not alter the encoding...

well, yes in a perfect world. Here it is well known problem. As far as I can see it is the only one solution to get the right info.

First I tried to fix encoding in the project code but it appeared to be too late, it simply did not work. Somewhere after MaxmindBinaryProvider and before project code it is completely corrupted (I did not debug so I cannot say where exactly).

Also I found that you did exact same fix in the GeoIpProvider.

@willdurand
Copy link
Member

Also I found that you did exact same fix in the GeoIpProvider.

Ah, then I'm screwed! :D

So, could you create a fixEncoding() method to the AbstractProvider and relies on it in both GeoIpProvider and MaxmindBinaryProvider?

@makasim
Copy link
Contributor Author

makasim commented Oct 17, 2013

@willdurand

So, could you create a fixEncoding() method to the AbstractProvider

done - formapro-forks@3c90e66

willdurand added a commit that referenced this pull request Oct 18, 2013
[1.7][maxmind] fix provider encondig. Force utf8.
@willdurand willdurand merged commit ddb35bf into geocoder-php:1.7 Oct 18, 2013
@willdurand
Copy link
Member

Great, thanks!

@willdurand
Copy link
Member

Tagged 1.7.1

@makasim makasim deleted the maxmind-binary-fix-encoding branch October 18, 2013 07:32
@makasim makasim restored the maxmind-binary-fix-encoding branch October 18, 2013 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants