javascript - 前端js json字符串base64_encode编码,提交后端中文乱码
业务流程
前端根据相关业务
1.进行数组转json的字符串类型
2.对该json字符串进行base64_encode
3.提交后端
现在问题是前端提交的base64,只要带有中文的,都会变成乱码,网上找了一些方式都不是很完美的解决了,到是解决了浏览器上的base64加密和解密后的中文乱码问题。
回复内容:
业务流程
前端根据相关业务
1.进行数组转json的字符串类型
2.对该json字符串进行base64_encode
3.提交后端
现在问题是前端提交的base64,只要带有中文的,都会变成乱码,网上找了一些方式都不是很完美的解决了,到是解决了浏览器上的base64加密和解密后的中文乱码问题。
json 使用 UTF-8,你用 base64 编码后,在服务端做 base64 解码后,也要当做 UTF-8 处理,如果当做 GBK 就会是乱码。
PS: base64 不是加密算法。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

In this chapter, we will understand the Environment Variables, General Configuration, Database Configuration and Email Configuration in CakePHP.

PHP 8.4 brings several new features, security improvements, and performance improvements with healthy amounts of feature deprecations and removals. This guide explains how to install PHP 8.4 or upgrade to PHP 8.4 on Ubuntu, Debian, or their derivati

To work with date and time in cakephp4, we are going to make use of the available FrozenTime class.

To work on file upload we are going to use the form helper. Here, is an example for file upload.

In this chapter, we are going to learn the following topics related to routing ?

CakePHP is an open-source framework for PHP. It is intended to make developing, deploying and maintaining applications much easier. CakePHP is based on a MVC-like architecture that is both powerful and easy to grasp. Models, Views, and Controllers gu

Validator can be created by adding the following two lines in the controller.

Visual Studio Code, also known as VS Code, is a free source code editor — or integrated development environment (IDE) — available for all major operating systems. With a large collection of extensions for many programming languages, VS Code can be c
