0

here is my test file

here is my full code (github.com/roroco/ro_article/tree/string-contains-null-byte)

I get "ArgumentError: string contains null byte" when run following code:

in ruby side:

get_article(File.read("test_file"))

In c side:

VALUE get_article(VALUE self, VALUE html) {
    str html2 = StringValueCStr(html);

the test file is so large, how to find null byte in this file? and how to make StringValueCStr work for all string even it contains "null byte"

anzeaucha
  • 157
  • 6

1 Answers1

2

when I use following code:

body = File.read("test_file")
result = body.inspect

I have "result" contains "\u0000"(my encoding is utf8), so the solution is

body.gsub(%r{\u0000}, "")

do it in ruby side or c side

anzeaucha
  • 157
  • 6