Professional Web Applications Themes

how to store and still search special characters in Python and MySql - MySQL

I have an MySQL database called zingers. The structure is: zid - integer, key, autoincrement keyword - varchar citation - text quotation - text I am having trouble storing text, as typed in latter two fields. Special characters and punctuation all seem not to be stored and retrieved correctly. Special apostrophes and single quotes from Microsoft Word are causing a special problem, even though I have ''ed all 's perhaps the encoding of the database itself should be different? it is currenlty latin_swedish_ci Input and output is through a browser. I think my problem may be that I need to ...

  1. #1

    Default how to store and still search special characters in Python and MySql

    I have an MySQL database called zingers. The structure is:

    zid - integer, key, autoincrement
    keyword - varchar
    citation - text
    quotation - text

    I am having trouble storing text, as typed in latter two fields.
    Special characters and punctuation all seem not to be stored and
    retrieved correctly.

    Special apostrophes and single quotes from Microsoft Word are causing
    a
    special problem, even though I have ''ed all 's

    perhaps the encoding of the database itself should be different? it
    is
    currenlty latin_swedish_ci

    Input and output is through a browser.

    I think my problem may be that I need to encode the string before
    saving it in the databse. Can anyone point me in the right direction
    here?

    here's the error message:

    UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position
    95: ordinal not in range(128)
    args = ('ascii', "update zingers set keywords =
    'a;Action;b;Religi... \n \n \n ' where zid = 422", 95, 96, 'ordinal
    not
    in range(128)')
    encoding = 'ascii'
    end = 96
    object = "update zingers set keywords = 'a;Action;b;Religi...
    \n
    \n \n ' where zid = 422"
    reason = 'ordinal not in range(128)'
    start = 95

    the characters I am trying to add are startquote and endquote copied
    and pasted from Microsoft Word.

    Can anyone help me on this?

    bests,

    -rsr-

    Ron Guest

  2. #2

    Default Re: how to store and still search special characters in Python andMySql

    Ron wrote: 

    Ron,

    Microsoft Word uses special characters not in latin_swedish_ci. You
    should be able to save the data in the database by using
    mysql_real_escape_string for the text (you may have to define the
    columns as BINARY). But I don't think you'll be able to display it in a
    browser.

    Better is to not use Microsoft Word for your input.

    --
    ==================
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    net
    ==================
    Jerry Guest

  3. #3

    Default Re: how to store and still search special characters in Python and MySql

    On Mon, 12 Feb 2007 05:51:13 -0500, Jerry Stuckle wrote: 
    >
    > Ron,
    >
    > Microsoft Word uses special characters not in latin_swedish_ci. You
    > should be able to save the data in the database by using
    > mysql_real_escape_string for the text (you may have to define the
    > columns as BINARY). But I don't think you'll be able to display it in a
    > browser.
    >
    > Better is to not use Microsoft Word for your input.[/ref]

    UTF-8 chts may also help. Those do support the characters in
    question.

    http://dev.mysql.com/doc/refman/5.0/en/cht-unicode.html

    This is not to say that making a single change to the table will fix the
    issue. There are *many* traps in the issue of character sets, but mysql
    at least provides options to help support a careful programmer in making
    a character-safe system.

    --
    It's not hard, it's just asking for a visit by the up fairy.
    -- Peter da Silva
    Peter Guest

Similar Threads

  1. Replies: 2
    Last Post: January 2nd, 04:29 PM
  2. xml and special characters
    By German Hernandez in forum Macromedia Flash Data Integration
    Replies: 4
    Last Post: May 14th, 12:02 AM
  3. Catalog Search (index) and special characters
    By Phil_Bocko@adobeforums.com in forum Adobe Acrobat Windows
    Replies: 0
    Last Post: April 26th, 06:57 PM
  4. PHP/Mysql/special characters problem
    By Mosher in forum PHP Development
    Replies: 12
    Last Post: January 7th, 04:41 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139