swe7 character set - strange mappings?

2002-04-02 Thread Philip Semanchuk

Hi everyone,
I am trying to understand what's going on here and I hope you can help me.
The swe7 characters set in swe7.conf has some really strange mappings in it.
For instance, the to_upper array maps ASCII 0x7E (a tilde) to 0x5E (a hat
aka Ctrl character). Why doesn't a tilde remain a tilde?

Stranger still is the entry in the sort_order array that maps tilde (0x7E)
to Y (0x59). And worst of all, the last letters in the Swedish alphabet (ä,
å and ö == 0xE4, 0xE5 and 0xF6) map to themselves which means that MySQL
sorts them case sensitively while the rest of the alphabet is sorted
case-INsensitively. Similar problems are present in the to_upper and
to_lower arrays so that lower('Ö') (e.g.) returns a capital letter.

I realize that I can make my own character set and I will do so in order to
fix the problems I am seeing. But first I want to make sure that the
problems I describe above are indeed problems due to a buggy character set
and not user error on my part. 

There's a good reference to the ISO-8859 character set that Swedish uses
here:
http://czyborra.com/charsets/iso8859.html#ISO-8859-1

I am using version 3.23.41.

Thanks in advance
Philip

filter fodder: sql query

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: SELECT w/LIKE on Swedish character ö finds ], why?

2002-03-27 Thread Philip Semanchuk

Ken,
That worked! THanks very much.

 -Original Message-
 From: Ken Menzel [mailto:[EMAIL PROTECTED]]
 Sent: den 26 mars 2002 21:25
 To: Philip Semanchuk
 Cc: [EMAIL PROTECTED]
 Subject: Re: SELECT w/LIKE on Swedish character ö finds ], why?
 
 
 Hi Philip,
   before running your test next time try this:
 
 vi /etc/my.cnf
 
 insert into this file:
 
 [mysqld]
 default-character-set  = swe7
 
 then stop mysql (mysqladmin shutdown)
 
 and restart (safe_mysqld)
 
 then try your test again.  It worked fine for me.
 
 Ken
 
 
  Philip Semanchuk wrote:
  
   Hi everyone,
   I am having a little trouble with searching for Swedish
 characters. When I
   SELECT using LIKE I get matches that I do not expect. I have
 created a
   simple test case that is entirely reproduced below. To summarize,
 I insert
   one row into a single-column table that contains the right square
 bracket
   character (ASCII 0x5d). When I search for the Swedish letter ö
 (ISO-8859-1
   0xf6) I find the row containing the right bracket.
  
   We're running RedHat 7.2 with nothing fancy added in as we're
 Linux novices
   and just playing around with the system to see how it works.
 MySQL -V
   produces this:
   mysql  Ver 11.15 Distrib 3.23.41, for redhat-linux-gnu (i386)
  
   Here's my test:
  
   mysql create database swedish_character_test;
   Query OK, 1 row affected (0.00 sec)
  
   mysql use swedish_character_test;
   Database changed
   mysql create table simple (name varchar(255) NOT NULL);
   Query OK, 0 rows affected (0.00 sec)
  
   mysql insert into simple (name) values (']');
   Query OK, 1 row affected (0.00 sec)
  
   mysql select name from simple where name like '%ö%';
   +--+
   | name |
   +--+
   | ]|
   +--+
   1 row in set (0.00 sec)
  
   I'd appreciate any help understanding why ö = ] in this case.
 
 

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: getting files into BLOBs and some more

2002-03-26 Thread Philip Semanchuk

 problem
 How do I insert files inte BLOBs?
 /problem

Tomas,
I use this PHP function to insert ASCII files into BLOBs. I think it would
also work for binary files but I have not tested it. Please note that there
are other (perhaps better) ways to insert into BLOBs but this works for me.

Good luck,
Philip

-- code starts here -- 
function RecordFile($pathname, $filename) {
  $filesize = filesize($pathname . / . $filename);
  
  $fp = fopen($pathname . / . $filename, r);
  $content = fread($fp, $filesize);
  fclose($fp);

  $content = addslashes($content); 
  $filename = addslashes($filename); 
  $pathname = addslashes($pathname);
  
  $s = insert into files (path, name, size, content) values (;
  $s = $s . ' . $pathname . ', ;
  $s = $s . ' . $filename . ', ;
  $s = $s . ' . $filesize . ', ;
  $s = $s . ' . $content . ';
  $s = $s . );
  
  if (mysql_query($s) == false) {  
lprint(Query failed:  . $s);
lprint(mysql_error());
  }
}

-- code ends here -- 

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




SELECT w/LIKE on Swedish character ö finds ], why?

2002-03-26 Thread Philip Semanchuk

Hi everyone,
I am having a little trouble with searching for Swedish characters. When I
SELECT using LIKE I get matches that I do not expect. I have created a
simple test case that is entirely reproduced below. To summarize, I insert
one row into a single-column table that contains the right square bracket
character (ASCII 0x5d). When I search for the Swedish letter ö (ISO-8859-1
0xf6) I find the row containing the right bracket.

We're running RedHat 7.2 with nothing fancy added in as we're Linux novices
and just playing around with the system to see how it works. MySQL -V
produces this:
mysql  Ver 11.15 Distrib 3.23.41, for redhat-linux-gnu (i386)

Here's my test:

mysql create database swedish_character_test;
Query OK, 1 row affected (0.00 sec)

mysql use swedish_character_test;
Database changed
mysql create table simple (name varchar(255) NOT NULL);
Query OK, 0 rows affected (0.00 sec)

mysql insert into simple (name) values (']');
Query OK, 1 row affected (0.00 sec)

mysql select name from simple where name like '%ö%';
+--+
| name |
+--+
| ]|
+--+
1 row in set (0.00 sec)


I'd appreciate any help understanding why ö = ] in this case.

Thanks in advance,
Philip

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: SELECT w/LIKE on Swedish character ö finds ], why?

2002-03-26 Thread Philip Semanchuk

THanks Makis, is this bug documented anywhere?

 -Original Message-
 From: savaidis [mailto:[EMAIL PROTECTED]]
 Sent: den 26 mars 2002 18:04
 To: Philip Semanchuk; [EMAIL PROTECTED]
 Subject: RE: SELECT w/LIKE on Swedish character ö finds ], why?
 
 
 I have the same problem with Greeks, it is a bug of MySQL.
 Try:
 1) Create the fields of the table with BINARY option.
 2) Use LIKE with BINARY option (slower)
 BINARY doesn't make the uppercase convertion.
 
 Makis
 
 
  -Original Message-
snip

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: SELECT w/LIKE on Swedish character ö finds ], why?

2002-03-26 Thread Philip Semanchuk

 If I were to take a wild guess I would say that the lower 7 bits of ö
 and ] match.  Which would mean that this isn't really text, ie 7-bit
 ASCII, but really BINARY data.  Which means either you need create
 table simple (name varchar(255) BINARY NOT NULL); or create table
 simple (name tinyblob NOT NULL);

Jim,
Thanks for the suggestion, but I already checked that and got no joy -- 

ö = 0xf6 = 0110
] = 0x5d = 01011101

Philip

 -Original Message-
 From: James Housley [mailto:[EMAIL PROTECTED]]
 Sent: den 26 mars 2002 18:06
 To: Philip Semanchuk
 Cc: '[EMAIL PROTECTED]'
 Subject: Re: SELECT w/LIKE on Swedish character ö finds ], why?
 
 
 Philip Semanchuk wrote:
  
  Hi everyone,
  I am having a little trouble with searching for Swedish 
 characters. When I
  SELECT using LIKE I get matches that I do not expect. I 
 have created a
  simple test case that is entirely reproduced below. To 
 summarize, I insert
  one row into a single-column table that contains the right 
 square bracket
  character (ASCII 0x5d). When I search for the Swedish 
 letter ö (ISO-8859-1
  0xf6) I find the row containing the right bracket.
  
  We're running RedHat 7.2 with nothing fancy added in as 
 we're Linux novices
  and just playing around with the system to see how it 
 works. MySQL -V
  produces this:
  mysql  Ver 11.15 Distrib 3.23.41, for redhat-linux-gnu (i386)
  
  Here's my test:
  
  mysql create database swedish_character_test;
  Query OK, 1 row affected (0.00 sec)
  
  mysql use swedish_character_test;
  Database changed
  mysql create table simple (name varchar(255) NOT NULL);
  Query OK, 0 rows affected (0.00 sec)
  
  mysql insert into simple (name) values (']');
  Query OK, 1 row affected (0.00 sec)
  
  mysql select name from simple where name like '%ö%';
  +--+
  | name |
  +--+
  | ]|
  +--+
  1 row in set (0.00 sec)
  
  I'd appreciate any help understanding why ö = ] in this case.
  
 
 If I were to take a wild guess I would say that the lower 7 bits of ö
 and ] match.  Which would mean that this isn't really text, ie 7-bit
 ASCII, but really BINARY data.  Which means either you need create
 table simple (name varchar(255) BINARY NOT NULL); or create table
 simple (name tinyblob NOT NULL);
 
 Give thoses a try.
 
 Jim
 -- 
 /\   ASCII Ribbon Campaign  .
 \ / - NO HTML/RTF in e-mail  .
  X  - NO Word docs in e-mail .
 / \ -
 [EMAIL PROTECTED]  http://www.FreeBSD.org The Power to Serve
 [EMAIL PROTECTED]  http://www.TheHousleys.net
 [EMAIL PROTECTED]  http://www.SimTel.Net
 -
 Progress (n) : What led from smart users in front of dumb terminals to
 dumb users in front of smart terminals.
 

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php