Forum OpenACS Q&A: Trouble of Japanese environment

Collapse
Posted by Isamu Yamamoto on
I applied Mr. Henry's patch to OpenACS3.2.4, and made Japanese environment.

In a certain URL, it is not displayed normally.
But, it is displayed normally that '.tcl' is deleted from this URL.

Why is it?

Example:
http://www.example.com/shared/community-member.tcl?user_id=3 ... NG
http://www.example.com/shared/community-member?user_id=3 ... OK
Collapse
Posted by Henry Minsky on
Ah, I see, that page shared/community-member.tcl uses a function called ad_return_top_of_page, which is explicitly setting the content type, and it doesn't set the charset properly (i.e., the content type should be "text/html; charset=shift_jis")

I think someone mentioned in another thread that they fixed this in my charset patches, by patching ad_return_top_of_page.

As a quick hack for Japanese, you could define

proc_doc ad_return_top_of_page {first_part_of_page {content_type "text/html; charset=shift_jis"}} "Re
turns HTTP headers plus the top of the user-ivisible page.  Saves a TCP packet (and therefore some ov
erhead) compared to using ReturnHeaders and an ns_write." {
    set all_the_headers "HTTP/1.0 200 OK
MIME-Version: 1.0
Content-Type: $content_type
"
     util_WriteWithExtraOutputHeaders $all_the_headers $first_part_of_page
}
Collapse
Posted by Henry Minsky on
That function is in /tcl/ad-utilities.tcl.preload

You should probably fix the other functions which set content type
in the same way, with a default content type of "text/html; charset=shift_jis"

Collapse
Posted by Isamu Yamamoto on
Thank you, Henry.

Although I fixed, a situation does not change.

So, the page displayed normally is the type which uses 'ns_return 200 text/html $page_content'.
The page which is not displayed normally is using 'ad_return_template' or 'ns_write'.

Actual URL is written below.
NG : http://openacs.trustbee.com:8080/shared/community-member.tcl?user_id=3
OK : http://openacs.trustbee.com:8080/shared/community-member?user_id=3

NG : http://openacs.trustbee.com:8080/poll/one-poll.tcl?poll_id=1
OK : http://openacs.trustbee.com:8080/poll/one-poll?poll_id=1

NG : http://openacs.trustbee.com:8080/wp/index.tcl?&show_user=all
OK : http://openacs.trustbee.com:8080/wp/index?&show_user=all
Collapse
Posted by David Walker on
.tcl files are served from ns_source in ad-aolserver-3.tcl.preload.
files without extensions are served from ad_handle_abstract_url in ad-abstract-url.tcl
whatever change you made to one make to the other and I think that'll fix it.
Collapse
Posted by Isamu Yamamoto on
Thank you, David !

I changed ns_sourceproc in ad-aolserver-3.tcl.preload, this trouble fixed.

# source $script
source_with_encoding $script

But, WimpyPoint is not still displayed normally.
Which Tcl file is used for a display of WimpyPoint?
http://openacs.trustbee.com:8080/wp/display/1/
Collapse
Posted by David Walker on
grep the tcl folder for "ns_register_proc" to find other potential places you'll need to change.

wimpypoint has 2 that are defined in wp-defs.tcl, wp_serve_style and wp_serve_presentation.
Collapse
Posted by Isamu Yamamoto on
Thank you, David !!

By adding the following line to wp_serve_presentation, it was displayed correctly.
ns_startcontent -type "text/html"

Where is the function of ns_startcontent defined?
What does this function perform?
Collapse
Posted by Henry Minsky on
ns_startcontent is a primitive command in AOLserver, added as
part of the ArsDigita patches to AOLserver.

It tells AOLserver to set the output character set encoding
to a given character set. Then, all output from Tcl (which
is UTF8 internally) is converted to that encoding as it
is sent to the network.

ns_startcontent is needed to be set before a page does ns_write, if
you want to ensure the output encoding conversion is done correctly.

ns_return returns a whole string at once, and will automatically
look at the MIME type and if it sees a "charset=xxx" it will
set that charset as the output encoding.

Collapse
Posted by Isamu Yamamoto on
Thank you, Henry.

My question was cleared.
Although I was using PHP before, I use OpenACS mainly after this. 😊