Skip to content

Commit

Permalink
Merge pull request #177 from nakagami/revert-176-master
Browse files Browse the repository at this point in the history
Revert "feat: Add character encoding conversion function"
  • Loading branch information
nakagami authored Jun 1, 2024
2 parents 9331e2b + dd4181d commit 2e42232
Showing 1 changed file with 0 additions and 121 deletions.
121 changes: 0 additions & 121 deletions wireprotocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ import (
"encoding/hex"
"errors"
"fmt"
"golang.org/x/text/encoding/charmap"
"golang.org/x/text/encoding/japanese"
"golang.org/x/text/encoding/korean"
"golang.org/x/text/encoding/simplifiedchinese"
"golang.org/x/text/encoding/traditionalchinese"
"math/big"
"net"
"os"
Expand Down Expand Up @@ -1393,7 +1388,6 @@ func (p *wireProtocol) paramsToBlr(transHandle int32, params []driver.Value, pro
for _, param := range params {
switch f := param.(type) {
case string:
f = p.encodeString(f)
b := str_to_bytes(f)
if len(b) < MAX_CHAR_LENGTH {
blr, v = _bytesToBlr(b)
Expand Down Expand Up @@ -1505,118 +1499,3 @@ func (p *wireProtocol) opCancel(kind int) error {
_, err := p.sendPackets()
return err
}

func (p *wireProtocol) encodeString(str string) string {
switch p.charset {
case "OCTETS":
return str
case "UNICODE_FSS", "UTF8":
return str
case "SJIS_0208":
enc := japanese.ShiftJIS.NewEncoder()
v, _ := enc.String(str)
return v
case "EUCJ_0208":
enc := japanese.EUCJP.NewEncoder()
v, _ := enc.String(str)
return v
case "ISO8859_1":
enc := charmap.ISO8859_1.NewEncoder()
v, _ := enc.String(str)
return v
case "ISO8859_2":
enc := charmap.ISO8859_2.NewEncoder()
v, _ := enc.String(str)
return v
case "ISO8859_3":
enc := charmap.ISO8859_3.NewEncoder()
v, _ := enc.String(str)
return v
case "ISO8859_4":
enc := charmap.ISO8859_5.NewEncoder()
v, _ := enc.String(str)
return v
case "ISO8859_5":
enc := charmap.ISO8859_5.NewEncoder()
v, _ := enc.String(str)
return v
case "ISO8859_6":
enc := charmap.ISO8859_6.NewEncoder()
v, _ := enc.String(str)
return v
case "ISO8859_7":
enc := charmap.ISO8859_7.NewEncoder()
v, _ := enc.String(str)
return v
case "ISO8859_8":
enc := charmap.ISO8859_8.NewEncoder()
v, _ := enc.String(str)
return v
case "ISO8859_9":
enc := charmap.ISO8859_9.NewEncoder()
v, _ := enc.String(str)
return v
case "ISO8859_13":
enc := charmap.ISO8859_13.NewEncoder()
v, _ := enc.String(str)
return v
case "KSC_5601":
enc := korean.EUCKR.NewEncoder()
v, _ := enc.String(str)
return v
case "WIN1250":
enc := charmap.Windows1250.NewEncoder()
v, _ := enc.String(str)
return v
case "WIN1251":
enc := charmap.Windows1251.NewEncoder()
v, _ := enc.String(str)
return v
case "WIN1252":
enc := charmap.Windows1252.NewEncoder()
v, _ := enc.String(str)
return v
case "WIN1253":
enc := charmap.Windows1252.NewEncoder()
v, _ := enc.String(str)
return v
case "WIN1254":
enc := charmap.Windows1252.NewEncoder()
v, _ := enc.String(str)
return v
case "BIG_5":
enc := traditionalchinese.Big5.NewEncoder()
v, _ := enc.String(str)
return v
case "GB_2312":
enc := simplifiedchinese.HZGB2312.NewEncoder()
v, _ := enc.String(str)
return v
case "WIN1255":
enc := charmap.Windows1255.NewEncoder()
v, _ := enc.String(str)
return v
case "WIN1256":
enc := charmap.Windows1256.NewEncoder()
v, _ := enc.String(str)
return v
case "WIN1257":
enc := charmap.Windows1257.NewEncoder()
v, _ := enc.String(str)
return v
case "KOI8R":
enc := charmap.KOI8R.NewEncoder()
v, _ := enc.String(str)
return v
case "KOI8U":
enc := charmap.KOI8U.NewEncoder()
v, _ := enc.String(str)
return v
case "WIN1258":
enc := charmap.Windows1258.NewEncoder()
v, _ := enc.String(str)
return v
default:
return str // If the specified charset is not supported, return the input string without any modification or encoding.
}
}

0 comments on commit 2e42232

Please sign in to comment.