Good all the time of day

We have a variable, with output - everything is fine, which is normally displayed when encoding ascii (and if the encoding is not written at all). The usual query mysql add variables in the database - karakozyabry (tried DB with different encodings). If you try to cut off the first character from the variable - again the caracas. Tell me, what could be the matter?

ps Maybe you need to assign a variable encoding?

  • And charset at the table (each column) looked? - Vfvtnjd
  • at least someone responded. cp1251_general_ci. mmm ... the value of the variable that I add to the database! = variable is the one if you select and copy it. Maybe this is the case? Maybe you need to reset the encoding? - sergey
  • one
    I coded myself for a long time with the coding. My advice to you is to start from scratch and all in a single encoding (and constantly follow it). And the encoding is better use UTF-8 - Avtostopom_do_Raya
  • the same story, where everything is utf-8 encoded. the question is different. if I add to the database of the karakozyabry (which the browser chews), it turns out that you need to change the encoding to Karakazyabr. just like that. it is not clear 8- ( - sergey

1 answer 1

It is desirable, but not necessary, to have UTF-8 everywhere. But in any case it is necessary to:

  1. after connecting to the database, you must specify in what encoding it will work with you.
  2. for string data in the database, you must specify the encoding
  3. for output to the browser, you must send the header with the specified encoding.

Then the problems with the encoding between the application, database and output can be forgotten.

  • I asked the question incorrectly. but to the question asked - thanks. I'll keep in mind - sergey