As I want to access some lower-level API to do I/O operation using CreateFile function syscall.CreateFile( name *uint16…)
While doing so I face a problem that the name parameter is of *uint16 but it should be an array ([]uint16) so that it can handle the string in the UTF-16 format. As we can see in the example provided by Microsoft -> link where TEXTmacro convert the string into wchar_t array or we can say []uint16.
Thanks in advance and sorry if I said anything wrong as I’m just a toddler in this field.
Low-level unsafe APIs like this can be tricky to get right. I’m curious why you, as a self-proclaimed toddler in the field, are trying to use them in the first place?
As I’m writing a blog on How to write a multi-threaded copy program in GoLang that’s why I’m doing so. I want to compare the performance of various ways to implement the copy operation. Like io.copy, os.readfile, and last with low-level API which is OS depended.
I’m able to run the program the main issue is that I can’t pass the proper name of the file as the function is only accepting the single UTF-16 character and I want to send an array
UTF16PtrFromString returns pointer to the UTF-16 encoding of the UTF-8 string s, with a terminating NUL added. If s contains a NUL byte at any location, it returns (nil, syscall.EINVAL).
UTF16PtrFromString returns pointer to the UTF-16 encoding of the UTF-8 string s, with a terminating NUL added. If s contains a NUL byte at any location, it returns (nil, syscall.EINVAL).