'普通字符 换成 UTF8字符
'返回包含UTF8字符格式的普通字符串（String 可以包含任何数据）
Function StrToUtf8(sStr as String ) as String
  Dim LenStr As Integer = Len(sStr)
  If LenStr = 0 Then Return ""
  Dim dst As String = String(LenStr * 2, 0)  '为输出Utf8预留空间
  Dim eLen As Integer, r As Any Ptr
  Dim wsStr As WString Ptr = CAllocate(LenStr * 2 + 2)  '必须转换为宽字符，不可以用CharToUTF转换，那不一样的编码。
  eLen = MultiByteToWideChar(CP_ACP, 0, StrPtr(sStr), LenStr, wsStr, LenStr * 2)
  r = WCharToUTF(UTF_ENCOD_UTF8, wsStr, eLen, StrPtr(dst), @eLen)
  Deallocate wsStr
  Function = Left(dst, eLen)
End Function
