Post NSIS。使用inetc插件发布俄语文本

Post NSIS。使用inetc插件发布俄语文本,post,encode,nsis,cyrillic,Post,Encode,Nsis,Cyrillic,我正在编写自定义卸载程序反馈窗口。有带默认原因的radiobutton和textfield,用户在其中编写自己的卸载原因。我将默认原因替换为字符串常量,并在没有任何问题的情况下发布它。如果我从textfield发送英文文本,它会工作。但不是俄罗斯人。服务器发送错误500,无法对我的数据进行编码。如何以正确的方式传递俄语数据 我正在构建Unicode安装程序。服务器需要UTF-8数据 $reason\u edit\u数据-文本字段中的文本 $CB##U状态-单选按钮状态(选中/未选中) INetC

我正在编写自定义卸载程序反馈窗口。有带默认原因的radiobutton和textfield,用户在其中编写自己的卸载原因。我将默认原因替换为字符串常量,并在没有任何问题的情况下发布它。如果我从textfield发送英文文本,它会工作。但不是俄罗斯人。服务器发送错误500,无法对我的数据进行编码。如何以正确的方式传递俄语数据

我正在构建Unicode安装程序。服务器需要UTF-8数据

$reason\u edit\u数据-文本字段中的文本 $CB##U状态-单选按钮状态(选中/未选中)


INetC仅限于UTF-16LE和活动的Ansi代码页。可能会添加一个
/UTF8DATA
开关,但同时您必须将post数据放入一个文件中:

!include LogicLib.nsh

Function WriteStringAsUTF8ToFile
Exch $1 ; File path
Exch
Exch $2 ; NSIS string & File handle
Push $0
Push $3 ; UTF-8 string buffer
System::Call 'KERNEL32::WideCharToMultiByte(i65001,i0,wr2,i-1,p0,i0,p0,p0)i.r0'
${If} $0 = 0
fail_simple:
    StrCpy $1 ""
${Else}
    System::Call '*(&i$0)p.r3'
    ${IfThen} $3 P= 0 ${|} Goto fail_simple ${|}
    System::Call 'KERNEL32::WideCharToMultiByte(i65001,i0,wr2,i-1,pr3,ir0,p0,p0)'
    IntOp $0 $0 - 1 ; Don't write the terminator
    FileOpen $2 $1 w
    ${IfThen} $2 == "" ${|} Goto fail ${|}
    System::Call 'KERNEL32::WriteFile(pr2,pr3,ir0,*i,p0)i.r0'
    ${IfThen} $0 = 0 ${|} StrCpy $1 "" ${|}
    FileClose $2
    Goto done
fail:
    StrCpy $1 ""
done:
    System::Free $3
${EndIf}
Pop $3
Pop $0
Pop $2
Exch $1
FunctionEnd


Section
InitPluginsDir
Push "${U+2115}SIS" ; String to write as UTF-8
Push "$PluginsDir\data.txt"
Call WriteStringAsUTF8ToFile
Pop $0
${If} $0 == ""
    MessageBox mb_ok "Error: Unable to write post data to file!"
${Else}
    inetc::post $0 /FILE /TOSTACK "http://example.com/post" "" /END
    Pop $1 ; "OK" on success
    Pop $2
    MessageBox mb_ok "Result: $1$\nResponse: $2"
${EndIf}
SectionEnd

您正在构建Ansi或Unicode安装程序吗?服务器期望什么?UTF-8?我正在构建一个Unicode安装程序。服务器期望UTF-8@Anders
!include LogicLib.nsh

Function WriteStringAsUTF8ToFile
Exch $1 ; File path
Exch
Exch $2 ; NSIS string & File handle
Push $0
Push $3 ; UTF-8 string buffer
System::Call 'KERNEL32::WideCharToMultiByte(i65001,i0,wr2,i-1,p0,i0,p0,p0)i.r0'
${If} $0 = 0
fail_simple:
    StrCpy $1 ""
${Else}
    System::Call '*(&i$0)p.r3'
    ${IfThen} $3 P= 0 ${|} Goto fail_simple ${|}
    System::Call 'KERNEL32::WideCharToMultiByte(i65001,i0,wr2,i-1,pr3,ir0,p0,p0)'
    IntOp $0 $0 - 1 ; Don't write the terminator
    FileOpen $2 $1 w
    ${IfThen} $2 == "" ${|} Goto fail ${|}
    System::Call 'KERNEL32::WriteFile(pr2,pr3,ir0,*i,p0)i.r0'
    ${IfThen} $0 = 0 ${|} StrCpy $1 "" ${|}
    FileClose $2
    Goto done
fail:
    StrCpy $1 ""
done:
    System::Free $3
${EndIf}
Pop $3
Pop $0
Pop $2
Exch $1
FunctionEnd


Section
InitPluginsDir
Push "${U+2115}SIS" ; String to write as UTF-8
Push "$PluginsDir\data.txt"
Call WriteStringAsUTF8ToFile
Pop $0
${If} $0 == ""
    MessageBox mb_ok "Error: Unable to write post data to file!"
${Else}
    inetc::post $0 /FILE /TOSTACK "http://example.com/post" "" /END
    Pop $1 ; "OK" on success
    Pop $2
    MessageBox mb_ok "Result: $1$\nResponse: $2"
${EndIf}
SectionEnd