summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/missdeer/golib/ic/ic.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2020-05-24 00:06:21 +0200
committerGitHub <noreply@github.com>2020-05-24 00:06:21 +0200
commit393f9e998b1b40aa59d3fb8794c3a73da38c3fb7 (patch)
tree2bc9b6e6abdbdc6d811b155997597bdae62bc7db /vendor/github.com/missdeer/golib/ic/ic.go
parentba0bfe70a8f07164e1341f4b094841acdad5c3a2 (diff)
downloadmatterbridge-msglm-393f9e998b1b40aa59d3fb8794c3a73da38c3fb7.tar.gz
matterbridge-msglm-393f9e998b1b40aa59d3fb8794c3a73da38c3fb7.tar.bz2
matterbridge-msglm-393f9e998b1b40aa59d3fb8794c3a73da38c3fb7.zip
Update dependencies / vendor (#1146)
Diffstat (limited to 'vendor/github.com/missdeer/golib/ic/ic.go')
-rw-r--r--vendor/github.com/missdeer/golib/ic/ic.go31
1 files changed, 31 insertions, 0 deletions
diff --git a/vendor/github.com/missdeer/golib/ic/ic.go b/vendor/github.com/missdeer/golib/ic/ic.go
new file mode 100644
index 00000000..9e414e36
--- /dev/null
+++ b/vendor/github.com/missdeer/golib/ic/ic.go
@@ -0,0 +1,31 @@
+package ic
+
+import "log"
+
+// Convert convert bytes from CJK or UTF-8 to UTF-8 or CJK
+func Convert(from string, to string, src []byte) []byte {
+ if to == "utf-8" {
+ out, e := ToUTF8(from, src)
+ if e == nil {
+ return out
+ }
+ log.Printf("converting from %s to UTF-8 failed: %v", from, e)
+ return src
+ }
+
+ if from == "utf-8" {
+ out, e := FromUTF8(to, src)
+ if e == nil {
+ return out
+ }
+ log.Printf("converting from UTF-8 to %s failed: %v", to, e)
+ return src
+ }
+ log.Println("only converting between CJK encodings and UTF-8 is supported")
+ return src
+}
+
+// ConvertString convert string from CJK or UTF-8 to UTF-8 or CJK
+func ConvertString(from string, to string, src string) string {
+ return string(Convert(from, to, []byte(src)))
+}