Understanding How to Handle Mixed Character Codes for Distributing Static HTML Files in the Public Folder in Ravel

Asked 2 years ago, Updated 2 years ago, 126 views

I would like to distribute static HTML files in laravel 6.x series.
I am trying to use the public folder, but there is a problem.

Example)

public/hogeA/index.html←Shift_JIS
public/hogeB/index.html←UTF-8
public/hogeC/index.html←Shift_JIS

If Shift_JIS and UTF-8 files are mixed in index.html per folder as shown above,
In this example, the index.html of hogeA and hogeC is garbled when viewed in the browser.

If you look at the content-type of the response header of hogeA, you can see that the reason is text/html; charset=UTF-8.

Is there a way to force the content-type of the html Response Header below the specific folder in the public folder to charset=Shift_JIS?

html laravel character-code shift-jis

2022-09-29 21:21

1 Answers

You can specify the META tag to return the appropriate encoding in the HTML file.

The following is an example of specifying UTF-8, but in the case of Shift_JIS, it seems to be "Shift_JIS".

reference:
Specify character encoding in HTML

<!DOCTYPE html>
<html lang="en">
<head>
<metacharset="utf-8"/>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>


2022-09-29 21:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.