Sure.
How is the text stored (accessible) in your code? Is it a wchar_t* or wstring? Either way, you'll want to find it's length in bytes and have a pointer to the string. Then convert that pointer to a char* and do file << hex << (int)char_ptr[i] for i from 0 to number of bytes.
You just force the conversion. char* ptr = (char*)my_wchar_t_pointer;. Although I don't know how much this is necessary. wchar_t is a numeric value like any other. You could do
1 2
for(int i = 0; i < str.length(); i++)
file << std::hex << (int)str[i];