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

panic when translating if //IGNORE is used #6

Open
GoogleCodeExporter opened this issue Sep 2, 2015 · 2 comments
Open

panic when translating if //IGNORE is used #6

GoogleCodeExporter opened this issue Sep 2, 2015 · 2 comments

Comments

@GoogleCodeExporter
Copy link

Used code:
package main

import (
    "code.google.com/p/go-charset/charset/iconv"
    "encoding/hex"
    "log"
    "fmt"
)

func main() {
    input := "é"
    t, err := iconv.Translator("ASCII//TRANSLIT", "UTF-8", 'x')
    if err != nil {
        log.Fatalf("Coult not get charset translator from UTF-8 to ASCII. Got error: %s\n", err)
        return
    }
    fmt.Print(hex.Dump([]byte(input)))
    n, cdata, err := t.Translate([]byte(input), true)
    if err != nil {
        log.Fatalf("Could not translate string '%s' to ASCII. Got error: %s\n", input, err)
    }
    fmt.Print(hex.Dump(cdata))
    output := string(cdata)
    log.Printf("Translated %d characters from UTF-8 ('%s') to ASCII ('%s')\n", n, input, output)
}


Go version:
go version go1.0.1


Error:
geertjohan@VirtKubuntu:~$ iconvtesting 
00000000  c3 a9                                             |..|
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
code.google.com/p/go-charset/charset/iconv.(*iconvTranslator).Translate(0xf84003
e400, 0xf840045112, 0x0, 0x200000001, 0x0, ...)
        /tmp/go-build714705259/code.google.com/p/go-charset/charset/iconv/_obj/iconv.cgo1.go:157 +0x4ea
main.main()
        /home/geertjohan/Workspaces/WorkspaceGo/devpath/src/iconvtesting/iconvtesting.go:20 +0x24c

goroutine 2 [syscall]:
created by runtime.main
        /home/geertjohan/Applications/go/src/pkg/runtime/proc.c:221

Original issue reported on code.google.com by [email protected] on 20 Jun 2012 at 7:40

@GoogleCodeExporter
Copy link
Author

Sorry I should have noted in the title that this concerns iconv translation.

Original comment by [email protected] on 20 Jun 2012 at 7:54

@GoogleCodeExporter
Copy link
Author

Original comment by [email protected] on 20 Jun 2012 at 9:16

  • Changed state: Accepted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant