OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



[SOLVED]Unicode characters in author fields

Are you responsible for making OJS work -- installing, upgrading, migrating or troubleshooting? Do you think you've found a bug? Post in this forum.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
What to do if you have a technical problem with OJS:

1. Search the forum. You can do this from the Advanced Search Page or from our Google Custom Search, which will search the entire PKP site. If you are encountering an error, we especially recommend searching the forum for said error.

2. Check the FAQ to see if your question or error has already been resolved.

3. Post a question, but please, only after trying the above two solutions. If it's a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a development question, try the OJS Development subforum.

[SOLVED]Unicode characters in author fields

Postby stabb » Sun Aug 12, 2007 9:55 pm

In importing an issue using the XML Plugin. Im noticing Unicode characters are being displayed as their respective code.

Ive tried editting the database entry, Disabling Persistent connections and re-importing the xml
(as reffered from viewtopic.php?f=8&t=2158&p=7265&hilit=unicode+characters+in+database#p7266)

but this doent work either.

Is there something I can do? I cant seem to understand why this is happening..?
Regards
James
Last edited by stabb on Mon Aug 13, 2007 12:41 pm, edited 2 times in total.
stabb
 
Posts: 47
Joined: Sat Mar 31, 2007 10:06 pm

Re: Unicode characters in author fields

Postby asmecher » Mon Aug 13, 2007 9:03 am

Hi James,

Are you using connection and database charset support (connection_charset and database_charset in config.inc.php)? Does your XML validate properly using a tool like xmllint or xmlspy?

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8869
Joined: Wed Aug 10, 2005 12:56 pm

Re: Unicode characters in author fields

Postby stabb » Mon Aug 13, 2007 11:12 am

Hi Alec
I have these two set in my config.inc
connection_charset = utf8
database_charset = utf8

I havent checked my xml's using those tools. They had no errors in XMLMArker however.

I'll check those others out soon.

Given that there was an XML problem. Shouldnt I be able to change the author name via the 'EDIT METADATA' link?
The macron still remains as ō.

The Macrons in the titles were all fine, it only happened with one author (I think theres only one with a macron).
SEE http://ojs.review.mai.ac.nz/index.php/MR/issue/view/1
(Mōheru Nikora)
Regards
James


**EDIT**
Im sure this is a database issue. I remember fixing this before via another users thread in this forum. He said to run a command on the database and it changed something but I cant seem to find the thread...??
stabb
 
Posts: 47
Joined: Sat Mar 31, 2007 10:06 pm

Re: Unicode characters in author fields

Postby asmecher » Mon Aug 13, 2007 11:42 am

Hi James,

Just to make sure I'm following properly -- editing the article's metadata via the "Edit Metadata" link doesn't correct the incorrect macron in the author's name?

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8869
Joined: Wed Aug 10, 2005 12:56 pm

Re: Unicode characters in author fields

Postby stabb » Mon Aug 13, 2007 12:26 pm

Whoops, Actually it all comes down to my misunderstanding.
I entered copied and pasted Mōrehu into the author field this time and its fine. I Somehow thought OJS translated ō to ō.

Thanks for the help Alec. Sorry to waste your time.
stabb
 
Posts: 47
Joined: Sat Mar 31, 2007 10:06 pm

Re: Unicode characters in author fields

Postby mj » Mon Aug 13, 2007 12:38 pm

Hi James,

Actually, OJS *should* convert ō to ō. I've found the cause and fixed this in the current CVS (see bug 2687 in Bugzilla).

You can solve the problem by changing the following code on line 385 in /core/String.inc.php:

From:
Code: Select all
    function html2utf($str) {
      // convert named entities to numeric entities
      $str = strtr($str, String::getHTMLEntities());

      // use PCRE-aware replace function to replace numeric entities
      $str = String::regexp_replace('~&#x([0-9a-f]+);~ei', 'String::code2utf(hexdec("\\1"))', $str);
      $str = String::regexp_replace('~&#([0-9]+);~e', 'String::code2utf(\\1)', $str);
    }


To:
Code: Select all
    function html2utf($str) {
      // convert named entities to numeric entities
      $str = strtr($str, String::getHTMLEntities());

      // use PCRE-aware replace function to replace numeric entities
      $str = String::regexp_replace('~&#x([0-9a-f]+);~ei', 'String::code2utf(hexdec("\\1"))', $str);
      $str = String::regexp_replace('~&#([0-9]+);~e', 'String::code2utf(\\1)', $str);
      
      return $str;
    }


Entirely my fault, and a little embarrasing.
mj
Site Admin
 
Posts: 304
Joined: Fri Mar 26, 2004 9:32 am
Location: Toronto, Canada

Re: [FIXED - silly mistake]Unicode characters in author fields

Postby stabb » Mon Aug 13, 2007 12:40 pm

Ok. I thought I made the mistake.
Cheers. I'll make the change now :)
Last edited by stabb on Thu Jan 03, 2008 10:56 pm, edited 1 time in total.
stabb
 
Posts: 47
Joined: Sat Mar 31, 2007 10:06 pm

Re: [SOLVED]Unicode characters in author fields

Postby stabb » Mon Aug 13, 2007 1:06 pm

Hi there mj

I dont seem to have this function in my string.inc.php code...?

classes/core/string.inc.php

Should I just add it right in?
stabb
 
Posts: 47
Joined: Sat Mar 31, 2007 10:06 pm

Re: [SOLVED]Unicode characters in author fields

Postby mj » Mon Aug 13, 2007 1:16 pm

Hi Jim,

That function is part of the Unicode overhaul that has been moved into the OJS 2.2 codebase, based on the helpful feedback of yourself and others over the past few months. I'd thought that you were running a semi-upgraded version of OJS because of our prior discussions around this issue.

At this point, you have two options:

  1. Wait until OJS 2.2 is released and upgrade then; not immediate, but more reliable since it will be thoroughly tested by then
  2. Upgrade specific files from the current CVS now; immediate but may have bugs / other impacts
I highly recommend route #1 if possible, but if you do choose to pursue route #2, the pertinent files to upgrade are:

Code: Select all
classes/core/Core.inc.php
classes/core/String.inc.php
classes/core/Request.inc.php
classes/form/Form.inc.php
classes/xml/XMLCustomWriter.inc.php


Hope this helps!
mj
Site Admin
 
Posts: 304
Joined: Fri Mar 26, 2004 9:32 am
Location: Toronto, Canada


Return to OJS Technical Support

Who is online

Users browsing this forum: No registered users and 8 guests