Skip to main content
May 18, 2006
Question

Japanese Characters working as URL parameters, turning to question marks when in URL string itself

  • May 18, 2006
  • 19 replies
  • 3016 views
I'm having some trouble getting coldfusion to see japanese characters in the URL string.

To clarify, if I have something like this:

http://my.domain.com/index.cfm?categorylevel0=Search&categorylevel1=%E3%82%A2%E3%82%B8%E3%82%A2%E3%83%BB%E3%83%93%E3%82%B8%E3%83%8D%E3%82%B9%E9%96%8B%E7%99%BA

All of my code works correctly and the server is able to pass the japanese characters to the database and retrieve the correct data.

If I have this instead:

http://my.domain.com/index.cfm/Search/%E3%82%A2%E3%82%B8%E3%82%A2%E3%83%BB%E3%83%93%E3%82%B8%E3%83%8D%E3%82%B9%E9%96%8B%E7%99%BA

My script (which works fine with English characters) parses CGI variables and converts these to the same URL parameters that I had in the first URL using a loop and a CFSET url.etc..

In the first example, looking at the CF debug info shows me what I expect to see:

URL Parameters:
CATEGORYLEVEL0=Search
CATEGORYLEVEL1=アジア・ビジネス開発

In the second example it shows me this:
URL Parameters:
CATEGORYLEVEL0=Search
CATEGORYLEVEL1=???·??????

Can anyone suggest means for debugging this? I'm not sure if this is a CF problem, an IIS problem, a JRUN problem or something else altogether that causes it to lose the characters if they are in the URL string but NOT as a parameter.
This topic has been closed for replies.

19 replies

Inspiring
May 19, 2006
maxgsilverscape wrote:
> 15:46:33.033 - java.io.IOException - in : line -1
> The filename, directory name, or volume label syntax is incorrect

no, i've used java before to do recursive dir deletes (in cf6) & one requirement
was to handle utf-8 named files/dirs, which it did. probably something about the
way cf handles this.
BKBK
Community Expert
Community Expert
May 20, 2006
My script (which works fine with English characters) parses CGI variables and converts these to the same URL parameters that I had in the first URL using a loop and a CFSET url.etc..
I suspect the problem lies here. The characters and URL parameters you produce are not in an encoding compatible with Japanese. To be sure, could we see your code?

May 19, 2006
Changing it to a cfm breaks it, and gives some more insight into where the problem is...

Exceptions

15:46:33.033 - java.io.IOException - in : line -1
The filename, directory name, or volume label syntax is incorrect


I recall there having been lots of issues with some of the file I/O concerning unicode with sun's jvm, not sure if these issues were ever resolved. I'm assuming not since this server runs a fairly new one.
Inspiring
May 19, 2006
maxgsilverscape wrote:
> Funny, I expected this not to work but just tried it and it served the page
> up perfectly. Now I'm really confused as to where the characters are getting
> lost .

can you serve a similarly named cf file? if not then it looks like cf. i'll ask
the cf team i guess.
May 19, 2006
Funny, I expected this not to work but just tried it and it served the page up perfectly. Now I'm really confused as to where the characters are getting lost .
Inspiring
May 19, 2006
maxgsilverscape wrote:
> I've been researching this quite a bit in the last day or two, and I'm leaning
> toward this being impossible on an en_US server. It assumes that the request is

cheap test, can you serve a utf-8 named htm file via IIS?
May 19, 2006
I've been researching this quite a bit in the last day or two, and I'm leaning toward this being impossible on an en_US server. It assumes that the request is looking for a file (understandably) and cant process that even though we are not actually looking for a file, but instead are giving URL parameters with slashes to create search engine friendly URL's. I'm not sure why it can pass the URL parameters along in UTF-8 but not the path part of the query string, but that seems to be the case just the same. Still open to suggestions if anyone has them.
Inspiring
May 18, 2006
maxgsilverscape wrote:
> Thanks for responding... this is CFMX7 with the most recent updater. I did use
> setEncoding and like I said, it works like a charm on URL parameters but it
> doesn't seem to have any effect on it when its done the other way.

ok i think i'm catching on. i've seen this on occasion using utf-8 names for
files--try writing out a cf page named in japanese or whatever on an en_US
server you should see something strange like "Either the Macromedia application
server is unreachable or it does not have a mapping to process this request."
when you try to access that file vai cf. i *think* it's an interaction between
cfserver & iis. i never really looked hard for a solution, let me dig into this.
May 18, 2006
Thanks for responding... this is CFMX7 with the most recent updater. I did use setEncoding and like I said, it works like a charm on URL parameters but it doesn't seem to have any effect on it when its done the other way.

I think the issue might be that you cant run setencoding on the cgi scope, just URL and form so when I run code like this:


<cfset cgipathinfo = cgi.SCRIPT_NAME & cgi.path_info>
<cfset query_string_length = Len(cgipathinfo)-Len(CGI.SCRIPT_NAME)>

<cfif query_string_length neq 0>
<cfset query_string = Right(cgipathinfo, query_string_length)>
<cfset i = 0>
<cfloop list="#query_string#" delimiters="/" index="currentcatname">
<cfset "url.categorylevel#i#" = currentcatname>
<cfset i = i + 1>
</cfloop>


it mangles the data looping through cgi.path_info/etc... Not sure how to get around that though.
Inspiring
May 18, 2006
maxgsilverscape wrote:
> I'm having some trouble getting coldfusion to see japanese characters in the
> URL string.

what version of cf? what encoding are you using? did you remember to use the
setEncoding() function?