Skip to content

Commit

Permalink
add string encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
VladimirTakeda committed Jan 17, 2024
1 parent e4201a7 commit d291e02
Show file tree
Hide file tree
Showing 12 changed files with 557 additions and 0 deletions.
15 changes: 15 additions & 0 deletions core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"unicode"
"unicode/utf8"

"github.com/djimenez/iconv-go"
"github.com/shinanca/gonec/externallibs/go-xlsx-templater"
"github.com/shinanca/gonec/names"
"moul.io/number-to-words"
Expand Down Expand Up @@ -420,6 +421,20 @@ func Import(env *Env) *Env {
return nil
}))

env.DefineS("ДекодироватьСтроку", VMFunc(func(args VMSlice, rets *VMSlice) error {
if len(args) != 3 {
env.Println()
return nil
}
cmdResult := string(args[0].(VMString))
output, err := iconv.ConvertString(cmdResult, string(args[1].(VMString)), string(args[2].(VMString)))
if err != nil {
return VMErrorEncoding
}
rets.Append(VMString(output))
return nil
}))

env.DefineS("чтениеизстрокиxml", VMFunc(func(args VMSlice, rets *VMSlice) error {
if len(args) != 1 {
env.Println()
Expand Down
2 changes: 2 additions & 0 deletions core/coreerrors.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ var (
VMErrorSetCellValue = errors.New("Ошибка при установки значения ячейки")
VMErrorAddSheet = errors.New("Ошибка при добавлении новой страницы")
VMErrorSaveXlsxFile = errors.New("Ошибка при записи xlsx файла")

VMErrorEncoding = errors.New("Ошибка при кодировании строки")
)

func VMErrorNeedArgs(n int) error {
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/covrom/decnum v0.0.0-20181120130125-279518e708a6
github.com/daviddengcn/go-colortext v1.0.0
github.com/dchest/siphash v1.2.3
github.com/djimenez/iconv-go v0.0.0-20160305225143-8960e66bd3da
github.com/hashicorp/go-cleanhttp v0.5.2
github.com/hashicorp/go-rootcerts v1.0.2
github.com/hashicorp/serf v0.9.8
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ github.com/daviddengcn/go-colortext v1.0.0 h1:ANqDyC0ys6qCSvuEK7l3g5RaehL/Xck9EX
github.com/daviddengcn/go-colortext v1.0.0/go.mod h1:zDqEI5NVUop5QPpVJUxE9UO10hRnmkD5G4Pmri9+m4c=
github.com/dchest/siphash v1.2.3 h1:QXwFc8cFOR2dSa/gE6o/HokBMWtLUaNDVd+22aKHeEA=
github.com/dchest/siphash v1.2.3/go.mod h1:0NvQU092bT0ipiFN++/rXm69QG9tVxLAlQHIXMPAkHc=
github.com/djimenez/iconv-go v0.0.0-20160305225143-8960e66bd3da h1:0qwwqQCLOOXPl58ljnq3sTJR7yRuMolM02vjxDh4ZVE=
github.com/djimenez/iconv-go v0.0.0-20160305225143-8960e66bd3da/go.mod h1:ns+zIWBBchgfRdxNgIJWn2x6U95LQchxeqiN5Cgdgts=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
Expand Down
3 changes: 3 additions & 0 deletions test/core/cmdexec.gnc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Params = ["-n", 9, "127.0.0.1"]
РезультатВыполнения = ВыполнитьКомандуСистемы("ping", Params);
Сообщить(ДекодироватьСтроку(РезультатВыполнения, "utf-8", "cp866"))
22 changes: 22 additions & 0 deletions vendor/github.com/djimenez/iconv-go/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

111 changes: 111 additions & 0 deletions vendor/github.com/djimenez/iconv-go/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

168 changes: 168 additions & 0 deletions vendor/github.com/djimenez/iconv-go/converter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d291e02

Please sign in to comment.