10 Replies Latest reply on Mar 26, 2009 2:33 AM by Newsgroup_User

    Dreamweaver CS4 Japanese encoding bug?

    Burak Ueda Level 3
      This occurs in mostly non-(X)HTML pages, like PHP or JavaScript, which has no tag as:
      quote:

      <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

      I create some scripts using JS or PHP, includes no Japanese characters in code itself, but code gets some data from database and prints it, which is UTF-8 encoded Japanese text.
      I save the code in UTF-8 format, and I can see UTF-8 in bottom-right corner indicator.
      However when I reload the document, it comes with Shift-JIS format.
      My default encoding is set to UTF-8, as well as encoding for new documents.

      Only workaround I found is, to put some Japanese text as a comment like:
      quote:


      //日本語
      <?php
      php code here
      ?>


      When I save this in UTF8, it stays UTF8.
      I am using Dreamweaver since 2004, and never had this problem before.
        • 1. Re: Dreamweaver CS4 Japanese encoding bug?
          CaryD Level 2
          You should make sure Adobe knows about this:

          Feature Request/ Bug Report Form
          http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform&product=21
          • 2. Re: Dreamweaver CS4 Japanese encoding bug?
            Level 7
            DeadManWalking wrote:
            > I create some scripts using JS or PHP, includes no Japanese characters in code
            > itself, but code gets some data from database and prints it, which is UTF-8
            > encoded Japanese text.
            > I save the code in UTF-8 format, and I can see UTF-8 in bottom-right corner.
            > However when I reload the document, it comes with Shift-JIS format.

            I don't understand what you are doing. How is Dreamweaver getting the data?

            If I create a JavaScript file that includes a string in Japanese,
            Dreamweaver saves the file as UTF-8, and when I reopen the file it is
            still UTF-8. The Japanese is correctly encoded and displayed.

            If you are getting data from a PHP script, the problem almost certainly
            lies in how PHP handles multibyte characters. For historical reasons,
            PHP handles Japanese using either EUC-JP or Shift_JIS. I haven't done
            any testing with storing Japanese as UTF-8 in a MySQL database because
            all my Japanese databases were created before MySQL supported Unicode.
            Moreover, PHP won't have full Unicode compliance until PHP 6, which has
            been promised for a long time, but still seems as far away as ever.

            --
            David Powers
            Adobe Community Expert, Dreamweaver
            http://foundationphp.com
            • 3. Re: Dreamweaver CS4 Japanese encoding bug?
              Burak Ueda Level 3
              David,

              I will try to explain simpler way:

              1. Create a new JS document. It opens in UTF8 mode.
              2. Write some scripts. The page doesn't include any Japanese chars.
              3. Save and close the file.
              4. Open the file, and it is in Shift-JIS format.

              I don't know where to begin with.
              1. Why encoding changes?
              2. Why in the earth it changes to SJIS while no Japanese text in it? I am not even using Japanese version of the software.
              • 4. Re: Dreamweaver CS4 Japanese encoding bug?
                Level 7
                DeadManWalking wrote:

                > 1. Why encoding changes?
                > 2. Why in the earth it changes to SJIS while no Japanese text in it? I am not
                > even using Japanese version of the software.

                That's a complete mystery. I have never heard of anything like that. I
                have some pages that are stored in Shift_JIS, but they don't affect any
                of my UTF-8 pages.

                --
                David Powers
                Adobe Community Expert, Dreamweaver
                http://foundationphp.com
                • 5. Re: Dreamweaver CS4 Japanese encoding bug?
                  ChrisBank Level 1
                  For JavaScript files there is no special way to say in the file what the encoding is. For formats like HTML, XML, and CSS there's someway to specify the charset of the file in the file itself. Since there is no direct way to tell with JavaScript files Dreamweaver usually falls back to the default encoding specified in the New Document preferences panel.

                  There are two exceptions for UTF-8. The first is if you saved your file with a Unicode Signature (BOM) which adds three hidden bytes to the start of your file and signals this file is always UTF-8 no matter what else is in it. The other case is non-ascii UTF-8 characters like those in Japanese or European accent characters. The UTF-8 encoding is pretty distinct for non-ascii characters so when Dreamweaver sees non-ascii characters that look like UTF-8 it assumes the file is UTF-8.

                  In your case it looks like the file has only ASCII characters in them so the default encoding was used. This doesn't really matter since all encodings treat ASCII characters the same way, it's only when you start using Japanese or European accents that the encoding really matter.
                  • 6. Re: Dreamweaver CS4 Japanese encoding bug?
                    Burak Ueda Level 3
                    Chris,
                    Thank you for the input.
                    quote:

                    Originally posted by: ChrisBank
                    For JavaScript files there is no special way to say in the file what the encoding is. For formats like HTML, XML, and CSS there's someway to specify the charset of the file in the file itself. Since there is no direct way to tell with JavaScript files Dreamweaver usually falls back to the default encoding specified in the New Document preferences panel.


                    Actually, there is a way. As I mentioned in my initial post, there is an encoding indicator in the bottom-right corner of the edit screen. This is same for the JavaScript files too. And you can actually change the encoding of JS files by:
                    clicking [Modify] menu and select [Page Properties]

                    quote:

                    Originally posted by: ChrisBank
                    There are two exceptions for UTF-8. The first is if you saved your file with a Unicode Signature (BOM) which adds three hidden bytes to the start of your file and signals this file is always UTF-8 no matter what else is in it. The other case is non-ascii UTF-8 characters like those in Japanese or European accent characters. The UTF-8 encoding is pretty distinct for non-ascii characters so when Dreamweaver sees non-ascii characters that look like UTF-8 it assumes the file is UTF-8.

                    In your case it looks like the file has only ASCII characters in them so the default encoding was used. This doesn't really matter since all encodings treat ASCII characters the same way, it's only when you start using Japanese or European accents that the encoding really matter.

                    This information helped my problem. When I save the document with BOM signature, forcing it to be UTF8 -no mater what-, the problem has solved.

                    But again, as I stated few times in my posts, my default encoding is set to UTF8, so even if Dreamweaver making assumptions, the default should be UTF8, no?

                    Probably DW is thinking "Hey! this guy's system is Japanese, so I should ignore the DW settings and set this to SJIS".

                    Anyway, I guess my problem has solved now, but I still think this is a "small" bug.

                    Thanks a lot.

                    • 7. Re: Dreamweaver CS4 Japanese encoding bug?
                      Level 7
                      DeadManWalking wrote:
                      > Actually, there is a way. As I mentioned in my initial post, there is an
                      > encoding indicator in the bottom-right corner of the edit screen. This is same
                      > for the JavaScript files too. And you can actually change the encoding of JS
                      > files by:
                      > clicking [Modify] menu and select [Page Properties]

                      That affects JavaScript and CSS files only while the file is open.

                      > When I save the document with BOM
                      > signature, forcing it to be UTF8 -no mater what-, the problem has solved.

                      Be careful using the BOM with PHP files. PHP interprets the BOM as
                      output, causing problems with the header() function and sessions.

                      > Probably DW is thinking "Hey! this guy's system is Japanese, so I should
                      > ignore the DW settings and set this to SJIS".

                      Bingo! If you're using a Japanese operating system that defaults to
                      Shift_JIS, that's what Dreamweaver will use in files that don't have a
                      way of indicating their encoding. The UTF-8 setting applies only to
                      files that have a meta tag or other method of declaring their encoding.

                      --
                      David Powers
                      Adobe Community Expert, Dreamweaver
                      http://foundationphp.com
                      • 8. Re: Dreamweaver CS4 Japanese encoding bug?
                        kiusau Level 2
                        On 03/24/2009 at 04:24:45 PM DeadmanWalking wrote:
                        quote:

                        Why in the earth it changes to SJIS while no Japanese text in it? I am not even using Japanese version of the software.

                        On 03/25/2009 at 08:44:34 AM David Powers wrote:
                        quote:

                        Bingo! If you're using a Japanese operating system that defaults to Shift_JIS, that's what Dreamweaver will use in files that don't have a way of indicating their encoding.

                        DeadManWalking does appear to be using an English version of DW in a Japanese operating environment, doesn't he?
                        • 9. Re: Dreamweaver CS4 Japanese encoding bug?
                          Burak Ueda Level 3
                          That is correct kiusau.

                          David,
                          Thanks for the heads-up on PHP and BOM signature issue.

                          Funny thing is, I didn't have this problem in CS3 :/

                          • 10. Re: Dreamweaver CS4 Japanese encoding bug?
                            Level 7
                            DeadManWalking wrote:
                            > Funny thing is, I didn't have this problem in CS3 :/

                            The difference is that CS4 is a multi-language version. It uses a
                            combination of your operating system and serial number to determine
                            which language to use for the menus. Previously, the Japanese and other
                            language versions of Dreamweaver were completely separate programs.

                            Some time ago, I submitted a feature request to the Dreamweaver
                            development team to specify the encoding for all pages, because I wanted
                            to embed Japanese in PHP include files. That's when I was told about
                            being able to use Page Properties. Now that the underlying program is
                            multi-language, I'll resubmit that request, because there is potential
                            for code being corrupted. I suspect it will be a rather low priority on
                            the list of things to do, though.

                            --
                            David Powers
                            Adobe Community Expert, Dreamweaver
                            http://foundationphp.com