Giter Club home page Giter Club logo

Comments (3)

garfeng avatar garfeng commented on July 24, 2024

因为不能通过&获取一个切片的实际数据的地址:
也就是:

// p1 指向 data1 的第一个元素的地址
var data1 [512]byte
p1 := &data1

// p2指向data2切片结构体的地址
data2 := make([]byte,512)
p2 := &data2

无法把这个p2作为参数调用c里的函数。

另外,无法在转换前知晓转换后的字符串有多长。

=-=
go要定义一个编译时不知长度的数组可以这么搞:

//#include <stdlib.h>
import "C"

arr := C.malloc(n)

跑路……

from iconv.

FrankWork avatar FrankWork commented on July 24, 2024

我也遇到这个问题了。

from iconv.

FrankWork avatar FrankWork commented on July 24, 2024

我的解决方案:

import 	"io/ioutil"
import "golang.org/x/net/html/charset"

func convrtToUTF(str string, origEncoding string) string {
    strBytes := []byte(str)
    byteReader := bytes.NewReader(strBytes)
    reader, _ := charset.NewReaderLabel(origEncoding, byteReader)
    strBytes, _ = ioutil.ReadAll(reader)
    return string(strBytes)
}

from iconv.

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.