FAQ
Hi Guys,
im trying to do simple conversion of byte to string

for i := 0; i < 10000; i++ {

  x = string(b)

}

-> 100ms works fine for single-byte characters, for unicode returns garbage


for i := 0; i < 10000; i++ {

  x = fmt.Sprintf("%v", b)

}

-> 9000ms, works ok with unicode


Any suggestions?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Ian Lance Taylor at Sep 24, 2014 at 9:03 pm

    On Wed, Sep 24, 2014 at 1:47 PM, Slawomir Pryczek wrote:
    im trying to do simple conversion of byte to string

    for i := 0; i < 10000; i++ {

    x = string(b)

    }

    -> 100ms works fine for single-byte characters, for unicode returns garbage


    for i := 0; i < 10000; i++ {

    x = fmt.Sprintf("%v", b)

    }

    -> 9000ms, works ok with unicode


    Any suggestions?
    Show all your code. I don't know the type of b and I can't figure out
    what you are trying to do.

    Ian

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Jasdel at Sep 24, 2014 at 9:25 pm
    do you have an example you can put into play.google.com where the unicode
    are returning garbage.

    As a simple test http://play.golang.org/p/VuIx6Azwtu takes a unicode byte
    array and outputs it as a string.

    cheers,
    Jason
    On Wednesday, September 24, 2014 1:47:51 PM UTC-7, Slawomir Pryczek wrote:

    Hi Guys,
    im trying to do simple conversion of byte to string

    for i := 0; i < 10000; i++ {

    x = string(b)

    }

    -> 100ms works fine for single-byte characters, for unicode returns garbage


    for i := 0; i < 10000; i++ {

    x = fmt.Sprintf("%v", b)

    }

    -> 9000ms, works ok with unicode


    Any suggestions?
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedSep 24, '14 at 8:47p
activeSep 24, '14 at 9:25p
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase