mirror of
https://github.com/LCTT/TranslateProject.git
synced 2025-01-25 23:11:02 +08:00
Merge branch 'master' of https://github.com/LCTT/TranslateProject into translating
This commit is contained in:
commit
54b611deb8
233
published/20230110.0 ⭐️⭐️ A guide to strings in MySQL.md
Normal file
233
published/20230110.0 ⭐️⭐️ A guide to strings in MySQL.md
Normal file
@ -0,0 +1,233 @@
|
||||
[#]: subject: "A guide to strings in MySQL"
|
||||
[#]: via: "https://opensource.com/article/23/1/strings-mysql"
|
||||
[#]: author: "Hunter Coleman https://opensource.com/users/hunterc"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "wxy"
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-15434-1.html"
|
||||
|
||||
MySQL 字符串指南
|
||||
======
|
||||
|
||||
![][0]
|
||||
|
||||
> 了解 MySQL 如何存储和显示你的字符串变量,以便你能更好地控制你的数据。
|
||||
|
||||
字符串是你在 MySQL 中使用的最常见的数据类型之一。许多用户在他们的数据库中插入和读取字符串,而没有认真地了解过它们。本文旨在让你深入了解 MySQL 如何存储和显示你的字符串变量,以便你能更好地控制你的数据。
|
||||
|
||||
你可以把字符串分成两类:二进制和非二进制。你可能在大多数时候想到的是非二进制字符串。非二进制字符串有字符集和排序的不同。另一方面,二进制字符串存储诸如 MP3 文件或图像等东西。即使你在二进制字符串中存储了一个词,比如“歌曲”,它的存储方式也与非二进制字符串不同。
|
||||
|
||||
我将重点讨论非二进制字符串。MySQL 中的所有非二进制字符串都与字符集和排序相关。字符串的字符集控制哪些字符可以存储在字符串中,而它的排序方式控制当你显示字符串时如何排序。
|
||||
|
||||
### 字符集
|
||||
|
||||
要查看你系统中的字符集,请运行以下命令:
|
||||
|
||||
```
|
||||
SHOW CHARACTER SET;
|
||||
```
|
||||
|
||||
这个命令将输出四列数据,包括字符集:
|
||||
|
||||
- 名称
|
||||
- 简要描述
|
||||
- 默认的排序方式
|
||||
- 字符集中每个字符的最大尺寸
|
||||
|
||||
MySQL 过去默认为 `latin1` 字符集,但自 8.0 版以来,默认为 `utf8mb4`。现在的默认排序方式是 `utf8mb4_0900_ai_ci`。`ai` 表示该排序对音调不敏感( `á` = `a`),而 `ci` 则指定它对大小写不敏感(`a` = `A`)。
|
||||
|
||||
不同的字符集将其字符存储在内存中不同大小的块中。例如,从上面的命令可以看出,存储在 `utf8mb4` 的字符被存储在 1 到 4 个字节大小的内存中。如果你想看看一个字符串是否包含多字节的字符,你可以使用 `CHAR_LENGTH()` 和 `LENGTH()` 函数。`CHAR_LENGTH()` 显示一个字符串包含多少个字符,而 `LENGTH()` 显示一个字符串有多少个字节,根据字符集的不同,它可能与一个字符串的字符长度相同,也可能不相同。下面是一个例子:
|
||||
|
||||
```
|
||||
SET @a = CONVERT('data' USING latin1);
|
||||
|
||||
SELECT LENGTH(@a), CHAR_LENGTH(@a);
|
||||
|
||||
+------------+-----------------+
|
||||
| LENGTH(@a) | CHAR_LENGTH(@a) |
|
||||
+------------+-----------------+
|
||||
| 4 | 4 |
|
||||
+------------+-----------------+
|
||||
```
|
||||
|
||||
这个例子表明,`latin1` 字符集以单字节为单位存储字符。其他字符集,如 `utf16`,允许多字节的字符:
|
||||
|
||||
```
|
||||
SET @b = CONVERT('data' USING utf16);
|
||||
|
||||
SELECT LENGTH(@b), CHAR_LENGTH(@b);
|
||||
|
||||
+------------+------------------+
|
||||
| LENGTH(@b) | CHAR_LENGTH(@b) |
|
||||
+------------+------------------+
|
||||
| 8 | 4 |
|
||||
+------------+------------------+
|
||||
```
|
||||
|
||||
### 排序
|
||||
|
||||
当你运行带有 `ORDER BY` 子句的 SQL 语句时,字符串排序方式将决定值的显示方式。你对排序方式的选择是由你选择的字符集决定的。当你运行上面的 `SHOW CHARACTER SET` 命令时,你看到了每个字符集的默认排序方式。你可以很容易地看到某个特定字符集的所有排序方式。例如,如果你想查看 `utf8mb4` 字符集允许哪些排序,请运行:
|
||||
|
||||
```
|
||||
SHOW COLLATION LIKE 'utf8mb4%';
|
||||
```
|
||||
|
||||
排序方式可以是不区分大小写的,也可以是区分大小写的,或者是二进制的。让我们建立一个简单的表,向其中插入一些值,然后用不同的排序方式查看数据,看看输出结果有什么不同:
|
||||
|
||||
```
|
||||
CREATE TABLE sample (s CHAR(5));
|
||||
|
||||
INSERT INTO sample (s) VALUES
|
||||
('AAAAA'), ('ccccc'), ('bbbbb'), ('BBBBB'), ('aaaaa'), ('CCCCC');
|
||||
|
||||
SELECT * FROM sample;
|
||||
|
||||
+-----------+
|
||||
| s |
|
||||
+-----------+
|
||||
| AAAAA |
|
||||
| ccccc |
|
||||
| bbbbb |
|
||||
| BBBBB |
|
||||
| aaaaa |
|
||||
| CCCCC |
|
||||
+-----------+
|
||||
```
|
||||
|
||||
在不区分大小写的情况下,你的数据会按字母顺序返回,但不能保证大写的单词会排在小写的单词之前,如下图所示:
|
||||
|
||||
```
|
||||
SELECT * FROM sample ORDER BY s COLLATE utf8mb4_turkish_ci;
|
||||
|
||||
+-----------+
|
||||
| s |
|
||||
+-----------+
|
||||
| AAAAA |
|
||||
| aaaaa |
|
||||
| bbbbb |
|
||||
| BBBBB |
|
||||
| ccccc |
|
||||
| CCCCC |
|
||||
+-----------+
|
||||
```
|
||||
|
||||
另一方面,当 MySQL 运行大小写敏感的搜索时,每个字母的小写将排在大写之前:
|
||||
|
||||
```
|
||||
SELECT * FROM sample ORDER BY s COLLATE utf8mb4_0900_as_cs;
|
||||
|
||||
+-----------+
|
||||
| s |
|
||||
+-----------+
|
||||
| aaaaa |
|
||||
| AAAAA |
|
||||
| bbbbb |
|
||||
| BBBBB |
|
||||
| ccccc |
|
||||
| CCCCC |
|
||||
+-----------+
|
||||
```
|
||||
|
||||
而按二进制排序方式将返回所有大写的值,然后再返回小写的值:
|
||||
|
||||
```
|
||||
SELECT * FROM sample ORDER BY s COLLATE utf8mb4_0900_bin;
|
||||
|
||||
+-----------+
|
||||
| s |
|
||||
+-----------+
|
||||
| AAAAA |
|
||||
| ccccc |
|
||||
| bbbbb |
|
||||
| BBBBB |
|
||||
| aaaaa |
|
||||
| CCCCC |
|
||||
+-----------+
|
||||
```
|
||||
|
||||
如果你想知道一个字符串使用哪种字符集和排序,你可以使用被恰当命名的 `charset` 和 `collation` 函数。运行 MySQL 8.0 或更高版本的服务器将默认使用 `utf8mb4` 字符集和 `utf8mb4_0900_ai_ci` 排序:
|
||||
|
||||
```
|
||||
SELECT charset('data');
|
||||
|
||||
+-------------------+
|
||||
| charset('data') |
|
||||
+-------------------+
|
||||
| utf8mb4 |
|
||||
+-------------------+
|
||||
|
||||
SELECT collation('data');
|
||||
|
||||
+--------------------+
|
||||
| collation('data') |
|
||||
+--------------------+
|
||||
| utf8mb4_0900_ai_ci |
|
||||
+--------------------+
|
||||
```
|
||||
|
||||
你可以使用 `SET NAMES` 命令来改变所使用的字符集或排序方式。
|
||||
|
||||
要从 `utf8mb4` 字符集改为 `utf16`,运行这个命令:
|
||||
|
||||
```
|
||||
SET NAMES 'utf16';
|
||||
```
|
||||
|
||||
如果你想选择默认以外的排序方式,你可以在 `SET NAMES` 命令中添加一个 `COLLATE` 子句。
|
||||
|
||||
例如,假设你的数据库存储西班牙语的单词。MySQL 的默认排序(`utf8mb4_0900_ai_ci`)将 `ch` 和 `ll` 视为两个不同的字符,并将它们排序。但在西班牙语中,`ch` 和 `ll` 是单独的字母,所以如果你想让它们按正确的顺序排序(分别排在 `c` 和 `l` 之后),你需要使用不同的排序。一个选择是使用 `utf8mb4_spanish2_ci` 排序方式:
|
||||
|
||||
```
|
||||
SET NAMES 'utf8mb4' COLLATE 'utf8mb4_spanish2_ci';
|
||||
```
|
||||
|
||||
### 储存字符串
|
||||
|
||||
MySQL 允许你为你的字符串值选择不同的数据类型。(甚至比其他流行的数据库,如 PostgreSQL 和 MongoDB 更多。)
|
||||
|
||||
下面是 MySQL 的二进制字符串数据类型的列表、它们的非二进制对应物,以及它们的最大长度:
|
||||
|
||||
- `binary`:`char`(255)
|
||||
- `varbinary`:`varchar`(65,535)
|
||||
- `tinyblob`:`tinytext`(255)
|
||||
- `blob`:`text`(65,535)
|
||||
- `mediumblob`:`mediumtext`(16,777,215)
|
||||
- `longblob`:`longtext`(4,294,967,295)
|
||||
|
||||
要记住的一件重要事情是,与被存储在可变长度的字段中的 `varbinary`、`varchar`、`text` 和 `blob` 类型不同(也就是说,只使用需要的空间),MySQL 将二进制(`binary`)和字符(`char`)类型存储在固定长度的字段。因此,像 `char(20)` 或 `binary(20)` 这样的值将总是占用 20 个字节,即使你在其中存储了少于 20 个字符。对于二进制类型,MySQL用 ASCII NUL 值(`0x00`)填充这些值,对于 字符类型,用空格填充。
|
||||
|
||||
在选择数据类型时要考虑的另一件事是,你是否希望在字符串后面的空格被保留或剥离。在显示数据时,MySQL 会从以字符数据类型存储的数据中剥离空格,但不会剥离 `varchar` 的空格。
|
||||
|
||||
```
|
||||
CREATE TABLE sample2 (s1 CHAR(10), s2 VARCHAR(10));
|
||||
|
||||
INSERT INTO sample2 (s1, s2) VALUES ('cat ', 'cat ');
|
||||
|
||||
SELECT s1, s2, CHAR_LENGTH(s1), CHAR_LENGTH(s2) FROM sample2;
|
||||
|
||||
+---------+---------+-----------------------------------+
|
||||
| s1 | s2 | CHAR_LENGTH(s1) | CHAR_LENGTH(s2) |
|
||||
+---------+---------+-----------------------------------+
|
||||
| cat | cat | 3 | 10 |
|
||||
+---------+---------+-----------------------------------+
|
||||
```
|
||||
|
||||
### 总结
|
||||
|
||||
字符串是数据库中最常用的数据类型之一,而 MySQL 仍然是当今最流行的数据库系统之一。我希望你能从这篇文章中学到一些新的东西,并能用你的新知识来提高你的数据库技能。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://opensource.com/article/23/1/strings-mysql
|
||||
|
||||
作者:[Hunter Coleman][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://opensource.com/users/hunterc
|
||||
[b]: https://github.com/lkxed
|
||||
[0]: https://img.linux.net.cn/data/attachment/album/202301/11/161410lh9944zpgjgmgs8t.jpg
|
@ -0,0 +1,78 @@
|
||||
[#]: subject: "Wow! CoolerMaster's MasterPlus Software to Go Open Source!"
|
||||
[#]: via: "https://news.itsfoss.com/coolermaster-open-source-software/"
|
||||
[#]: author: "Sourav Rudra https://news.itsfoss.com/author/sourav/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: "wxy"
|
||||
[#]: reviewer: "wxy"
|
||||
[#]: publisher: "wxy"
|
||||
[#]: url: "https://linux.cn/article-15433-1.html"
|
||||
|
||||
酷冷至尊(CoolerMaster)的 MasterPlus 软件即将开源
|
||||
======
|
||||
|
||||
> MasterPlus 将被彻底改造并推出开源版本?听起来不错!
|
||||
|
||||
![][1]
|
||||
|
||||
大多数游戏/外设软件套装要么是专有的,要么是没有对 Linux 的官方支持。
|
||||
|
||||
因此,我们必须不断寻找开源工具来配置我们的硬件以获得原生功能。
|
||||
|
||||
像 [Piper][2]、[OpenRGB][3]、[Solaar][4] 等在这些情况下都很有用。
|
||||
|
||||
但是,有时候,即使是这些也是不够的。
|
||||
|
||||
幸运的是,[酷冷至尊(CoolerMaster)][5] 已经决定发布其 [MasterPlus][6] 软件的开源版本,旨在为其散热器和第三方的散热器提供服务。
|
||||
|
||||
**虽然这并不能保证它可以用在 Linux 系统上,但我们绝对可以期待它。**
|
||||
|
||||
此举也应该鼓励雷蛇和罗技这样公司考虑制作精简过的开源工具。
|
||||
|
||||
让我们看看酷冷至尊打算怎么做。
|
||||
|
||||
### MasterPlus 开源版本:我们目前所知的情况
|
||||
|
||||
![酷冷至尊 Masterplus 改版][7]
|
||||
|
||||
**酷冷至尊在最近的 [CES 2023][8] 活动中透露了他们计划发布新的 MasterPlus 开源版本**。感谢来自 [Boring Text Reviews][9] 的 Albert 让我们注意到了这一点。
|
||||
|
||||
**预期会有什么?** 对 MasterPlus 软件进行了全面的重新设计,有一个 API 插件系统,允许非酷冷至尊散热器与之整合。
|
||||
|
||||
他们已经澄清,酷冷至尊的独有功能不能配合其他散热器一起工作。因此,诸如检测 AIO 散热器的泄漏或计算 PSU 的效率等,都不能对第三方产品进行跟踪。
|
||||
|
||||
相反,该应用程序将只支持读取基本的性能信息,如温度和风扇速度,并能够配置 ARGB 设备。
|
||||
|
||||
如果你问我,**这总比没有好。** 而且,如果你的系统碰巧使用了酷冷至尊的组件,这对你来说是一个令人兴奋的消息!
|
||||
|
||||
酷冷至尊还展示了 API 系统的潜在应用,让它与一个照片应用程序挂钩,用它来控制集成在电脑机箱侧面的辅助显示器。
|
||||
|
||||
此外,他们还介绍了其软件的全面云整合。但遗憾的是,这部分不会开源。
|
||||
|
||||
**什么时候?** 我们还没有 MasterPlus 开源的具体发布日期。
|
||||
|
||||
但是,如果让我猜,2023 年的某个时候是最好的选择。
|
||||
|
||||
💬 _即使该工具没有被确认可以在 Linux 上工作,对开源工具来说也是一个好的开始,不是吗?你怎么看?_
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.itsfoss.com/coolermaster-open-source-software/
|
||||
|
||||
作者:[Sourav Rudra][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[wxy](https://github.com/wxy)
|
||||
校对:[wxy](https://github.com/wxy)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://news.itsfoss.com/author/sourav/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://news.itsfoss.com/content/images/size/w2000/2023/01/coolermaster-masterplus-goes-opensource.png
|
||||
[2]: https://github.com/libratbag/piper
|
||||
[3]: https://openrgb.org
|
||||
[4]: https://github.com/pwr-Solaar/Solaar
|
||||
[5]: https://www.coolermaster.com
|
||||
[6]: https://masterplus.coolermaster.com
|
||||
[7]: https://news.itsfoss.com/content/images/2023/01/CoolerMaster_MasterPlus_Revamp-1.png
|
||||
[8]: https://www.ces.tech
|
||||
[9]: https://boringtextreviews.com/exclusive-say-goodbye-to-bloated-closed-source-software-coolermaster-to-release-new-open-source-version-of-its-software-with-api-integration-and-it-can-work-with-other-coolers-too
|
@ -0,0 +1,92 @@
|
||||
[#]: subject: "OBS Studio 29 Release Has Little in Store For Linux"
|
||||
[#]: via: "https://news.itsfoss.com/obs-studio-29-release/"
|
||||
[#]: author: "Sourav Rudra https://news.itsfoss.com/author/sourav/"
|
||||
[#]: collector: "lkxed"
|
||||
[#]: translator: " "
|
||||
[#]: reviewer: " "
|
||||
[#]: publisher: " "
|
||||
[#]: url: " "
|
||||
|
||||
OBS Studio 29 Release Has Little in Store For Linux
|
||||
======
|
||||
|
||||
OBS Studio 29 is an exciting release with key improvements across all platforms.
|
||||
|
||||
![OBS Studio 29 Release Has Little in Store For Linux][1]
|
||||
|
||||
[OBS Studio][2] is one of the most popular open-source screen recording and streaming software.
|
||||
|
||||
Used by many Linux users and content creators, it has a pretty neat set of tools and features that lets you record and stream content.
|
||||
|
||||
Its last major release was back in September 2022, which brought in native support for Apple Silicon, updated UI, improved color support, and more.
|
||||
|
||||
Its next release, v29, seems to be a bit interesting, but not so much for Linux users 😞
|
||||
|
||||
### OBS Studio 29: What's New?
|
||||
|
||||
![obs studio 29][3]
|
||||
|
||||
This release has plenty of improvements and fixes; some of the highlights include the following:
|
||||
|
||||
- **Media key support for Linux**
|
||||
- **New Audio Filters**
|
||||
- **Improved NVIDIA Video and Audio Filters**
|
||||
- **Better Encoder Support**
|
||||
- **Various Fixes and Improvements**
|
||||
|
||||
**Media key support:** You can finally use the media keys on your keyboard to control the playback or the volume with OBS on Linux.
|
||||
|
||||
**New Audio Filters:** OBS Studio 29 features two new audio filters, an upward compressor filter, and a 3-band equalizer filter.
|
||||
|
||||
**Improved NVIDIA Video and Audio Filters:** Various improvements have been made to these filters.
|
||||
|
||||
A new Mask Refresh slider has been added, alongside support for temporal processing, that is supposed to provide better quality masking.
|
||||
|
||||
**Better Encoder Support:** Well, OBS Studio 29 received improved support for several encoders, such as:
|
||||
|
||||
- AMD AV1 Encoder for[RX7000 series][4] of GPUs on Windows.
|
||||
- Intel AV1 Encoder for [Arc GPUs][5] on Windows.
|
||||
- Intel HEVC Encoder on Windows.
|
||||
- Native HEVC and ProRes encoders for macOS.
|
||||
|
||||
> 📋 Note that support for these encoders is only for either Windows or macOS.Sadly, they miss out on support for Linux. We hope these are added in a future release of OBS Studio.
|
||||
|
||||
**Various Fixes and Improvements:** Apart from the ones listed above, OBS Studio 29 features plenty of other changes, such as:
|
||||
|
||||
- Websockets 5.1.0
|
||||
- The replay buffer's memory limit is now limited to 75% of installed system RAM, instead of being fixed to 8 GB.
|
||||
- Support for encryption and authentication for SRT and RIST outputs.
|
||||
- Ability to inspect and/or mute individual browser docks.
|
||||
- Support for higher refresh rates in case of video captures.
|
||||
|
||||
For more technical details, you can go through the [official release notes][6].
|
||||
|
||||
### Download OBS Studio 29
|
||||
|
||||
To get the latest OBS Studio 29, you can get the [Flatpak][7], the recommended method.
|
||||
|
||||
You can also explore other installation methods mentioned in its official download page.
|
||||
|
||||
[OBS Studio 29][8]
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://news.itsfoss.com/obs-studio-29-release/
|
||||
|
||||
作者:[Sourav Rudra][a]
|
||||
选题:[lkxed][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://news.itsfoss.com/author/sourav/
|
||||
[b]: https://github.com/lkxed
|
||||
[1]: https://news.itsfoss.com/content/images/size/w2000/2023/01/obs-studio-29-release.png
|
||||
[2]: https://obsproject.com
|
||||
[3]: https://news.itsfoss.com/content/images/2023/01/OBS_Studio_29.png
|
||||
[4]: https://en.wikipedia.org/wiki/Radeon_RX_7000_series
|
||||
[5]: https://www.intel.in/content/www/in/en/products/details/discrete-gpus/arc.html
|
||||
[6]: https://github.com/obsproject/obs-studio/releases/tag/29.0.0
|
||||
[7]: https://flathub.org/apps/details/com.obsproject.Studio
|
||||
[8]: https://obsproject.com/download
|
@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (Drwhooooo)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
Loading…
Reference in New Issue
Block a user