Skip to content

Commit

Permalink
Merge pull request traccar#5466 from zhanghx0905/master
Browse files Browse the repository at this point in the history
Fix: Set UTF-8 Encoding for Proper Rendering of Chinese Characters in Server Title
  • Loading branch information
tananaev authored Nov 18, 2024
2 parents 249f25e + 2020f60 commit 4c0156e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/main/java/org/traccar/web/OverrideFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets;

@Singleton
public class OverrideFilter implements Filter {
Expand Down Expand Up @@ -70,12 +71,12 @@ public void doFilter(ServletRequest request, ServletResponse response, FilterCha
String description = server.getString("description", "Traccar GPS Tracking System");
String colorPrimary = server.getString("colorPrimary", "#1a237e");

String alteredContent = new String(wrappedResponse.getCapture())
String alteredContent = new String(wrappedResponse.getCapture(), StandardCharsets.UTF_8)
.replace("${title}", title)
.replace("${description}", description)
.replace("${colorPrimary}", colorPrimary);

byte[] data = alteredContent.getBytes();
byte[] data = alteredContent.getBytes(StandardCharsets.UTF_8);
response.setContentLength(data.length);
response.getOutputStream().write(data);

Expand Down

0 comments on commit 4c0156e

Please sign in to comment.