Japanese is garbled on the page opened in save_and_open_page of capybara.

Asked 1 years ago, Updated 1 years ago, 123 views

The page opened using save_and_open_page in capybara will be garbled only in Japanese as shown below.

Character garbled

Please let me know if there is any way to fix it.

ruby ruby-on-rails rspec capybara

2022-09-29 21:27

2 Answers

In the head of layouts/application.html.erb

<metahttp-equiv="Content-Type" content="text/html;charset=utf-8"/>

The garbled characters have been corrected by adding .


2022-09-29 21:27

If you want to use meta http-equiv to specify charset in the HTML header, write it at the beginning of the head tag.

If Japanese strings are used in title tags before charset specification, the browser implementation may cause garbled characters.


2022-09-29 21:27

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.