Skip to content
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

ASCII translit not working #11

Open
pierrre opened this issue Feb 5, 2014 · 3 comments
Open

ASCII translit not working #11

pierrre opened this issue Feb 5, 2014 · 3 comments

Comments

@pierrre
Copy link

pierrre commented Feb 5, 2014

My Go code:

package main

import (
    "fmt"
    iconv "github.com/djimenez/iconv-go"
)

func main() {
    su := "aé"
    sa, err := iconv.ConvertString(su, "UTF-8", "ASCII//TRANSLIT")
    if err != nil {
        panic(err)
    }
    fmt.Println(sa)
}

Result:

a?

Expected result:

ae

Native iconv command:

echo "aé" | iconv -f "UTF-8" -t "ASCII//TRANSLIT"
@djimenez
Copy link
Owner

djimenez commented Feb 5, 2014

This was odd, I didn't see any immediate reason why this shouldn't work for you - since I'm passing the provided strings directly to the iconv_open without any manipulation.

When I looked at the main function for the iconv program however, i saw they were doing a setlocale(LC_ALL, "") before opening an iconv descriptor and processing data.

When I did a similar call with cgo in an init method, everything worked as expected. I'm not sure if that's appropriate for my library to do though. There doesn't already seem to be a way to do the same as setlocale without using cgo, which makes me worry its not a very nice thing to just do.

I'll put the change on a branch until i know more

@pierrre
Copy link
Author

pierrre commented Feb 6, 2014

Yes it works! :)
I get "ae" as expected.

@pierrre
Copy link
Author

pierrre commented Feb 6, 2014

I had the same problem in PHP.
I fixed it with a locale tweak/setting.

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

No branches or pull requests

2 participants