mirror of
https://github.com/thoughtbot/capybara-webkit
synced 2023-03-27 23:22:28 -04:00
convert to utf8 string
This commit is contained in:
parent
46a842f63d
commit
246597c36b
2 changed files with 17 additions and 4 deletions
|
@ -1,3 +1,5 @@
|
|||
# -*- encoding: UTF-8 -*-
|
||||
|
||||
require 'spec_helper'
|
||||
require 'capybara-webkit'
|
||||
|
||||
|
@ -50,18 +52,28 @@ describe Capybara::Session do
|
|||
body = <<-HTML
|
||||
<html><body>
|
||||
<strong>Hello</strong>
|
||||
<span>UTF8文字列</span>
|
||||
</body></html>
|
||||
HTML
|
||||
[200,
|
||||
{ 'Content-Type' => 'text/html', 'Content-Length' => body.length.to_s },
|
||||
{ 'Content-Type' => 'text/html; charset=UTF-8', 'Content-Length' => body.length.to_s },
|
||||
[body]]
|
||||
end
|
||||
end
|
||||
|
||||
it "inspects nodes" do
|
||||
before do
|
||||
subject.visit("/")
|
||||
end
|
||||
|
||||
it "inspects nodes" do
|
||||
subject.all(:xpath, "//strong").first.inspect.should include("strong")
|
||||
end
|
||||
|
||||
it "utf8 string" do
|
||||
utf8str = subject.all(:xpath, "//span").first.text
|
||||
utf8str = utf8str.dup.force_encoding('UTF-8') if Kernel.const_defined?(:Encoding) # for Ruby 1.9
|
||||
utf8str.should eq('UTF8文字列')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -123,8 +123,9 @@ void Connection::writeResponse(bool success, QString &response) {
|
|||
else
|
||||
m_socket->write("failure\n");
|
||||
|
||||
QString responseLength = QString::number(response.size()) + "\n";
|
||||
QByteArray response_utf8 = response.toUtf8();
|
||||
QString responseLength = QString::number(response_utf8.size()) + "\n";
|
||||
m_socket->write(responseLength.toAscii());
|
||||
m_socket->write(response.toAscii());
|
||||
m_socket->write(response_utf8);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue