Comments (5)
i just tried an alter on the description
field to make it utf8. need to do more research to see what cause this behavior to start, but i suspect an upgrade to mysql would have done it.
so far i do not see more messages like this in error.log, but we'll see...
from website.
here is the table before and after, and the alter command.
alter table `stations` change `description` `description` varchar(255) character set utf8mb4 default NULL;
mysql> show create table stations \G
*************************** 1. row ***************************
Table: stations
Create Table: CREATE TABLE `stations` (
`station_url` varchar(255) NOT NULL,
`description` varchar(255) DEFAULT NULL,
`latitude` float DEFAULT NULL,
`longitude` float DEFAULT NULL,
`station_type` varchar(64) DEFAULT NULL,
`station_model` varchar(128) DEFAULT NULL,
`weewx_info` varchar(64) DEFAULT NULL,
`python_info` varchar(64) DEFAULT NULL,
`platform_info` varchar(128) DEFAULT NULL,
`last_addr` varchar(16) DEFAULT NULL,
`last_seen` int DEFAULT NULL,
UNIQUE KEY `index_url` (`station_url`),
KEY `index_addr` (`last_addr`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
mysql> show create table stations \G
*************************** 1. row ***************************
Table: stations
Create Table: CREATE TABLE `stations` (
`station_url` varchar(255) NOT NULL,
`description` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
`latitude` float DEFAULT NULL,
`longitude` float DEFAULT NULL,
`station_type` varchar(64) DEFAULT NULL,
`station_model` varchar(128) DEFAULT NULL,
`weewx_info` varchar(64) DEFAULT NULL,
`python_info` varchar(64) DEFAULT NULL,
`platform_info` varchar(128) DEFAULT NULL,
`last_addr` varchar(16) DEFAULT NULL,
`last_seen` int DEFAULT NULL,
UNIQUE KEY `index_url` (`station_url`),
KEY `index_addr` (`last_addr`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1
from website.
actually, that latin1
is kind of obvious. when did that appear? pretty sure it was not part of the original table creation. so perhaps a mysql upgrade added that to make it explicit, thus breaking any inserts that contain utf8?
sorry, but character encodings are one of my many weaknesses
from website.
the latin1 is there apparently because i did not specify a characterset when i originally created the tables eons ago, so it defaulted to latin1. apparently mysql 8 (running on weewx.com as of this writing nov 2022) defaults to utf8 (not sure whether that is 3-byte or 4-byte).
i'm not crazy about altering everything in the database. description should obviously accept non-latin characters, but should any other fields?
from website.
Interesting.
Internally, I'm sure MySQL stores it as a byte string. However, it appears that the database engine is also enforcing character type safety. That is, if you declare the field as Latin-1, then try to store something that uses non-Latin-1 characters, it will declare an error.
When it comes time to print the field out, the MySQL client will use the encoding to figure out what code point to use.
I believe that UTF-8 domain names are valid these days, although most DNS servers don't support them. To future proof things, I would use utf-8 encoding for station_url
as well.
The other fields should be fine.
It's an ancient article, but I recommend Joel Spolsky's The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets. It set me straight now 20 years ago!
from website.
Related Issues (4)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from website.