Giter VIP home page Giter VIP logo

Comments (6)

sijms avatar sijms commented on August 27, 2024

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

from go-ora.

sijms avatar sijms commented on August 27, 2024

v2.7.18
add support for charset ID 846 and also update code to use SetStringConverter

from go-ora.

aca avatar aca commented on August 27, 2024

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

//"KO16MSWIN949" : 846,

from go-ora.

sijms avatar sijms commented on August 27, 2024

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

from go-ora.

aca avatar aca commented on August 27, 2024

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)

from go-ora.

sijms avatar sijms commented on August 27, 2024

the implementation is correct
also test my update if it is working or not
i update connection_string.go and un-comment the line

from go-ora.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.