javascript - How to fix text encoding errors in title and description from Youtube Api v3?
问题描述
I'm a novice React web developer, and i'm building a simple web React App which uses Youtube API v3, in order to render and display video according to the user search.
When i make a call from Youtube API V3, I have some issues related to some characters displayed in my title and description.
I've correctly added meta charSet="UTF-8"
or even meta charset="utf-8
in Head inside my index.html, but this error stills not fixed.
const VideoDetail = ({ video }) => {
if (!video) {
return <div>Loading...</div>;
}
const videoSrc = `https://www.youtube.com/embed/${video.id.videoId}`;
return (
<div>
<div className="ui embed">
<iframe src={videoSrc} />
</div>
<div className="ui segment">
<h4>{video.snippet.title}</h4>
<p>{video.snippet.description}</p>
</div>
</div>
);
};
For example, the description of a video is rendered like this : my Beautiful Home & my wonderful car.
Instead, The sentence should actually be like this: my Beautiful Home and my wonderful car.
解决方案
推荐阅读
- java - 异常处理程序不能作为控制器建议
- javascript - 使用 Firebase 实时数据库 JS SDK 测试数据库连接的方法?
- react-native - 如何在 React Native/Expo 中存储/读取静态内容数据
- swift - 如何获得接受字符串或字符串数组的函数?
- python - 由于不支持 Ray Wheel,GCP 上的 Ray 集群启动失败
- mysql - 与客户 SQL 查询作斗争
- javascript - GAS Google Script - 如何复制值并粘贴到另一个单元格
- flutter - 如何根据用户操作在 Flutter 中的 Navigator.pop() 上设置不同的过渡动画?
- java - Spring Boot Security - IllegalStateException:无法在任何请求之后配置 antMatchers
- mysql - 使用 sequelize 将子关联中的列展平