Skip to content

panic when translating if //IGNORE is used #6

@GoogleCodeExporter

Description

@GoogleCodeExporter
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 gjr19...@gmail.com on 20 Jun 2012 at 7:40

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions