1
1
12rbah2020-09-18 14:55:59
go
12rbah, 2020-09-18 14:55:59

Why isn't all the text output to the console?

I am converting text from utf-16 to utf-8, but the following problem occurs, that the entire text is not displayed or is displayed with "\r". (I scavenge files under ubuntu that were saved in Windows). Is there any way to properly remove this?

//так отображается часть текста
  fmt.Printf("%v\n",binaryFIleFormat.UTF16BytesToString(bb,binary.LittleEndian))
        //если добавить # перед v то
        //так отображается весь текст, но появляются \r в разных местах
  fmt.Printf("%#v\n",binaryFIleFormat.UTF16BytesToString(bb,binary.LittleEndian))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Mirilaczvili, 2020-09-18
@12rbah

https://play.golang.org/p/9RpSsyoL4_6
Here, in the combined example, it outputs both times

No. 2
"Orga

Unicode is a non-trivial thing, and one would expect some sequence of bytes to be illegal from the point of view of the standard.
Credits: https://gist.github.com/juergenhoetzel/2d9447cdf5c...

1
12rbah, 2020-09-18
@12rbah

You can do this, and the text will be displayed, but it's still not entirely clear why it was not displayed in the console before

bb2 := bytes.ReplaceAll(bb,[]byte{0xd,0x0},[]byte{})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question