alexbrainman / odbc

odbc driver written in go
BSD 3-Clause "New" or "Revised" License
352 stars 140 forks source link

Is this driver support well for gbk or gb-2312 encoding, and so on #95

Closed snowcrumble closed 7 years ago

snowcrumble commented 7 years ago

My db is gb-2312 or gbk encoding, not utf-8. and there are some trouble:

  1. when I use this driver to read type char, for example "char[12]" for 6 chinese word, because in gbk encodind, a chinese word use 2 char, I can only read 4 chinese word.
  2. when I use this driver to read type varchar, for example "varchar[12]" for 6 chinese word, driver will panic like below, only the varchar[12] column store less then 4 chinese word driver work well. `[/home/d5000/anshan]$ ./dbsafe panic: runtime error: slice bounds out of range

goroutine 1 [running]: github.com/alexbrainman/odbc.(BindableColumn).Value(0xc42001a4c0, 0x7f0f6c0063b0, 0x1, 0x51c260, 0xc42000c6a0, 0x0, 0x0) /root/gopath/src/github.com/alexbrainman/odbc/column.go:247 +0xd5 github.com/alexbrainman/odbc.(Rows).Next(0xc42000e068, 0xc42001a580, 0x4, 0x4, 0x4, 0x4) /root/gopath/src/github.com/alexbrainman/odbc/rows.go:35 +0xb4 database/sql.(Rows).nextLocked(0xc420016180, 0xc420067de8) /usr/local/go/src/database/sql/sql.go:2149 +0x6c database/sql.(Rows).Next.func1() /usr/local/go/src/database/sql/sql.go:2134 +0x3c database/sql.withLock(0x7f0c20, 0xc4200161b0, 0xc420067e28) /usr/local/go/src/database/sql/sql.go:2545 +0x65 database/sql.(*Rows).Next(0xc420016180, 0x55a12e) /usr/local/go/src/database/sql/sql.go:2135 +0x83 main.main() /root/gopath/src/PSGSM/commonlib/common/example/dbsafe/main.go:23 +0xe3`

I would be very glad if you could help me

alexbrainman commented 7 years ago

@SnowCrumble it is difficult for me to suggest anything, because you provided very little information about your problem. What database you use? What ODBC driver you use? What does your program (that crashed) look like? Can I reproduce it myself? What steps should I follow to reproduce?

Thank you.

Alex

snowcrumble commented 7 years ago

Thank you for reply. My database is very noteless, names "DM", in chinese is "达梦", and I use unixODBC 2.3.0 in linux with kernel 2.6.32.41. And I use isql command has the same problem, this trouble seemingly not your driver's problem. This issue should be closed

alexbrainman commented 7 years ago

Sounds good. Thank you for explaining.

dotqi commented 6 years ago

When data is listed as varchar, if the column is saved in Chinese, the data obtained is garbled. There is a way to deal with it. Thank you