Tools for encoding multi-language character

HKcow

Joined: 2006-01-06
Posts: 15
Posted: Fri, 2006-01-06 06:34

First of all, thanks to the great features of the G2. I am now hosting a web site for my friends to share photos.

However, as we have thousands of photos (They are uploaded to the G2 already with inside appropriate albums) and surely we don't want to enter the title, summary, description one by one using the G2 web interface.

We have the existing db storing the title, summary, description for each photos already (Actually it is a spreadsheet only). We want to generate a sql file with thousands of lines like

update g2_item set g_title = 'xxx', g_sumary = 'yyy' where g_title = 'zzz.jpg'
...
...

and execute the file using phpmyadmin... Well, it should be kind of easy job. However our description contains Chinese and some Japanese. As I know, g2 did not write the raw charset like UTF-8 directly to the db, instead, g2 will encode it and write the encoded data in ASCII.

My problem is, could anyone tell me the encoding formula, or the way that I can encode a UTF-8 character to the appropriate encoded ASCII that g2 uses? I don't know php but know some VB, Java. Anyway, if there is no existing tools to do so, please let me know which part of the php code that g2 is using to encode character for me to reference.

Many Thanks. Your help really can save me a lot of times to input the description one by one!

THX!

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2006-01-06 06:52

if the database accepts utf8, g2 inserts the data in utf8. else ascii encoded, but it's the db that does this for you. you should just insert utf8 encoded data.

you can and should use g2's api.

modules/core/clases/GalleryCoreApi.class
GalleryCoreApi::convertToUtf8();

g2 uses just the normal php mysql/postgresql connection to insert UTF8 strings into the database.

 
HKcow

Joined: 2006-01-06
Posts: 15
Posted: Fri, 2006-01-06 07:03

Oh~ I am confused. I can see the utf8_general_ci is used for both the database, table and field. However if I select the g_item table using phpmyadmin, the result can't be decoded and monster is shown.

 
HKcow

Joined: 2006-01-06
Posts: 15
Posted: Fri, 2006-01-06 07:24

Moreover, I tried to patch the data inside the table g2_item, I changed an item's field g_summary from NULL to 'ABC', but the G2 web album did not refresh the changes.

However if i change the summary using the web interface, the field is updated in the db... is there another place that g2 store the photo's summary?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Fri, 2006-01-06 08:51

after manually changing the database stuff, you need to run
yourGalleryUrl/lib/support/ -> cache -> delete database / template cache

 
HKcow

Joined: 2006-01-06
Posts: 15
Posted: Fri, 2006-01-06 09:47

THX, but i am getting problem in updating the DB.
As you said, G2 write the chinese directly to mysql using raw utf8.
However, I can't read back the value written by g2 using phpmyadmin.
If I insert a value by phpmyadmin, g2 can't decode the character property.

However, if i turn on logging in mysql using --log
I can see both the insert statement are the same in the log and the chinese can be shown property in the log as well.

So, where is the problem? Is that because the way that mysql store the same string differently from g2 and phpmyadmin?