How about use `c_string_to_jsval`? 
And the codes
```
std::string utf8;
    if (ret_val) {
        utf8 = ret_val;
    }
```
will be not needed.