m2j
m2j

Reputation: 1160

How to deal with UTF-8 vs. Latin-1 encoding issues in PHP+MySQL

I tried to store GPS latitude and longitude value in DMS format with the degree and apostrophe in mysql with php.

The previous solution is convert it into Decimal.

Is there any particular datatype to store the value in mysql with the symbols like below:

12°53′17″N
80°13′52″E

The proble is,it replaces with 12°53′17″ N, 80°13′52″ E.

Upvotes: 0

Views: 181

Answers (1)

BetaDev
BetaDev

Reputation: 4674

Create your table by setting the character set as utf-UTF-8 Unicode. If you specify the Character set for the table as Unicode then it will accept the original latitude/longitude Values. Reference code for SQL:

ALTER TABLE `gps`
DEFAULT CHARACTER SET=utf8;

The following works for me

CREATE TABLE `gps` (
  `lat` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

Upvotes: 1

Related Questions