Closed aca closed 11 months ago
there is a way to define custom encode and decode through implement IStringConveter interface and pass this value to connection after connect now I am upgrading this to be used directly with database/sql package. also i will try to add support for charset 846 to the package
v2.7.18 add support for charset ID 846 and also update code to use SetStringConverter
Thanks, but still panics. Should I omit charset ID in DSN?
panic: charset KO16MSWIN949 is not supported by the driver
goroutine 1 [running]:
main.main()
---/ledger/example/go-ora/main.go:36 +0x23f
exit status 2
yes don't use charset in dsn as you are using the same charset of the server if there is panic would you please share an example code
Oh, I tried with SetStringConverter
and it worked.
But I'm just not sure it is correct implementation. Can you correct me if I'm wrong?
Now I think I can replace go-ora, which I had to change encoding every message manually. Thanks!
import (
"context"
"database/sql"
"encoding/base64"
"github.com/davecgh/go-spew/spew"
go_ora "github.com/sijms/go-ora/v2"
"github.com/sijms/go-ora/v2/converters"
"golang.org/x/text/encoding/korean"
)
// Server configuration
// NLS_NCHAR_CHARACTERSET ,AL16UTF16
// NLS_CHARACTERSET ,KO16MSWIN949
type KO16MSWIN949Converter struct {}
func (KO16MSWIN949Converter) Encode(in string) []byte {
v, err := korean.EUCKR.NewEncoder().String(in)
if err != nil {
panic(err)
}
return []byte(v)
}
func (KO16MSWIN949Converter) Clone() converters.IStringConverter {
return KO16MSWIN949Converter{}
}
func (KO16MSWIN949Converter) GetLangID() int {
return 846
}
func (KO16MSWIN949Converter) Decode(in []byte) string {
v, err := korean.EUCKR.NewDecoder().Bytes(in)
if err != nil {
panic(err)
}
return string(v)
}
go_ora.SetStringConverter(db, KO16MSWIN949Converter{}, nil)
the implementation is correct also test my update if it is working or not i update connection_string.go and un-comment the line
Hi, I'm having issue with godror and replace it with go-ora. cgo dependancies really annoying in our environment. But our old legacy oracle db uses different charset. Is it possible to support different charset?