Finding length of Japanese Characters

Hi ,
We are developing multi lingo site and for that when the user key in japanese characters, their length differs from the length of english characters and so for that we have to get the length that the user keyed in and if it the length more than what we allow to show error message as when trying to store it in database it will through exception as message truncated something like that.
if any one knows about that please reply.
Thanks in advance

Be careful when you divelop multi language
codes, uni-codes does not always mean 2-byte
characters, under at least 1 new industrial
standard (i.e. GB 18030 that China proposed
in 2000) we can see 4-byte characters.

Similar Messages

  • Find and Replace Japanese characters in pdf file on iPhone

    Hi eveybody !
    I want to find and replace Japanese characters in pdf on iPhone.
    I using zlib to deflate stream - endstream block and extract text.It's work fine with latin-text.
    But when i work with japanese characters , I don't know how to do it ?
    I decode a sample japanese pdf file, and I know that each Japanese characters are performances as hex string : "<01b7><0e230a23>..."
    But i don't know how to convert Japanese characters to the hex string like that.
    Can evrybody help me?
    Thanks!

    Searching is the same process as extracting - since it's about turning page content into something understandable.  So that still remains what you need to learn/understand - of course, referring back to all the previous sections about font formats, etc.
    Replacing in PDF is EXTREMELY DIFFICULT for two reasons - subset fonts and explicit glyph positioning.  Have you determine (conceptually, if nothing else) how you plan to addresses these two issues?
    PDF doesn't do UTF8 for page content - so don't worry about that.

  • Problem with Gui_download using ASC File type - japanese characters

    Hi,
    During upgrade,while downloading data for japanese characters using GUI_DOWNLOAD Function module with file type as 'ASC', the space between 2 fields data getting much wider compared to 4.6C Version ws_download Function module's  data.
    Example: the gap between first field data and second field data in ECC 6.0 is 6 characters length,but in 4.6C it is 2 characters length.
    Is there any possibility to get the results similar to 4.6c version.Please give your valueable suggestions.
    Thanks
    BalaNarasimman

    Hi Sandra
    Please find the detailed information for your questions.
    1.Internal table content before download:During Debugging,it was observed that internal table content was same in both versions.For testing,i used only brand new data(Transaction entry).
    2.Download with code Page conversion:Yes,codepage parameter 4103 was explicitly passed into GUI_DOWNLOAD Function module.Also the front end code page which is used by system is 4110 . No errors occured.
    3.System is an Unicode system only.
    4.Actually this 6 character does not refer the byte value,only the gap between 2 fields data is getting referred in ECC 6.0.Please find the below example.
    Example - File data after Download:
    ECC 6.0: Field1            Field2      (gap - 6 characters space between 2 fields data)  Using GUI_Download
    data       u0152©Ïu201Dԍu2020      EN                               
         4.6C: Field1            Field2       (gap - 2 characters space between 2 fields data) Using WS_Download
         data    u0152©Ïu201Dԍu2020  EN    
    Note:Special characters are Japanese characters:

  • MySQL Japanese characters

    Hello,
    I already searched the froums for a soluton to my problem but couldn't find any for it though I tried some of the things that were proposed. I have a MySQL Database where I store Japanese characters in SJIS. I tested if they are in SJIS and they are.
    I am using mysql 4.1.3b-beta, mysql-connector-java-3.0.14, JBuilderX (jdk 1.4.2), and OS XP.
    When I try to retrieve the data I only get a square, then a some character, then a square, then another character,... but not the actual Kanji/Kana. I can display Japanese characters correctly when I retrieve them from a file, so I don't think it's a problem with the font.
    My code is as follows:
    public void testDB(){
    String result ="";
    Connection con = null;
    Statement st = null;
    try
    Properties prop = new java.util.Properties();
    prop.put("user","");
    prop.put("password","");
    prop.put("useUnicode", "true");
    prop.put("characterEncoding","SJIS");
    String url = "jdbc:mysql://localhost/japanese";
    //Class.forName ("org.gjt.mm.mysql.Driver");
    Class.forName ("com.mysql.jdbc.Driver").newInstance ();
    con = DriverManager.getConnection (url, prop);
    result= "Database connection established";
    st = con.createStatement();
    ResultSet rs = null;
    String querry1 = "SELECT * FROM jp";
    PreparedStatement pstmt = con.prepareStatement(querry1);
    rs = pstmt.executeQuery();
    int i = 0;
    while (rs.next()) {
    result = rs.getString(1);
         jTable1.setFont(new Font("Arial Unicode MS",0,15));
    jTable1.setValueAt(result,i,0);
    i++;
    catch (Exception e)
    // result = "Cannot connect to database server";
    finally
    if (con != null)
    try
    con.close ();
    // result ="Database connection terminated";
    catch (Exception e) { /* ignore close errors */ }
    I hope someone can help me as MySql is my last option after I already discovered that I couldn't use MS Access and Foxpro because the ODBC:JDBC bridge doesn't work correctly for unicode.
    On a side note as I am new to MySql after installing version mysql4.1.3b. I no longer have the mysqld.exe but only mysqld-opt.exe. So I am using this instead. But I don't think that can be responsible for my problem.
    Thaks for any help.
    S

    I see your original question was sent in August so maybe you have found an answer ?.. Would be interesting to see how you fixed it.
    I was having a similar sort of problem but managed to fix it by looking at the fonts available to Java on my machine and setting the font used by the graphics object to one of the japanese fonts. (nb. I see in your code you are setting the font to arial unicode, maybe setting it to a japanaese font name would be enough)
    Hopefully the following will give you some help.
    // this line sticks the name of all fonts in the graphics environment in an array
    String[] nameArray = GraphicsEnvironment
                   .getLocalGraphicsEnvironment()
                   .getAvailableFontFamilyNames();
    // I know that the last two fonts are for japanese characters. I chose the font name second from the end of the array.
    int listfonts=nameArray.length-2 ;
    //then I sent the font for the g2 object.
    Font fontselec ;
    fontselec = new Font(nameArray[listfonts],Font.PLAIN,24) ;
    g2.setFont(fontselec) ;
    best regards
    Graham

  • Java PrintService printing Chinese/Japanese characters output is garbled.

    Hi Java Gurus,
    I have been spending the whole day trying to make our text printing application able to print non-western Characters (e.g. Chinese and Japanese) as part of our requirements. But I am constantly getting garbled output when I print a UTF-8 formatted text file containing Chinese characters. I've been trying to switch the DocFlavor types (e.g. byte array in UTF 8, input stream auto sense, UT8-8, etc) but I couldn't simply make it work.
    Here is our test method:
         public void testPrintText(String fileName) throws Exception {
              FileInputStream textStream = new FileInputStream(fileName);
              File file = new File(fileName);
              String fileContent = FileUtils.readFileToString(file);
              DocFlavor flavor = DocFlavor.BYTE_ARRAY.TEXT_PLAIN_UTF_8;
              //DocFlavor flavor = DocFlavor.READER.TEXT_PLAIN;
              InputStreamReader isr = new InputStreamReader(textStream, "utf-8");
              DocAttributeSet das = new HashDocAttributeSet();
              //System.out.println("host encoding: " + flavor.hostEncoding);
              Doc mydoc = new SimpleDoc(fileContent.getBytes("utf-8"), flavor, das);
              //Doc mydoc = new SimpleDoc(textStream, flavor, das);
              PrintRequestAttributeSet pas = new HashPrintRequestAttributeSet();
              pas.add(new PrinterName("\\\\fsinec\\Canon iR5055 PCL6", null));
              PrintService[] services = PrintServiceLookup.lookupPrintServices(flavor, pas);
              PrintService defaultService = PrintServiceLookup.lookupDefaultPrintService();
              System.out.println("DEBUG: " + defaultService.getClass().getName());
              if(services.length == 0) {       
                   if(defaultService == null) {
                        //no printer found
                   } else {            
                        //print using default
                        DocPrintJob job = defaultService.createPrintJob();
                        job.print(mydoc, pas);
              } else {        
                   //built in UI for printing you may not use this
                   PrintRequestAttributeSet attSet = new HashPrintRequestAttributeSet();
                   for(int ctr=0; ctr<services.length; ctr++) {
                        PrintService printService = services[ctr];
                        System.out.println("COTS DEBUG: " + defaultService.getClass().getName());
                   //attSet.add();
                   PrintService service = null;
                   if(services.length == 1) {
                        //assume that there is no other printer with the name \\\\fsinec\\Canon iR5055 PCL6
                        //resulting to fetch the printer services to only one (1) element.
                        service = services[0];
                   /* open a dialog box
                   * PrintService service =
                        ServiceUI.printDialog(null, 200, 200, services, defaultService, flavor, attSet);*/
                   if (service != null) {           
                        DocPrintJob job = service.createPrintJob();
                        job.print(mydoc, attSet);
    Please help me on this.
    Thanks.

    This could be of different reeasons...
    1) Make sure your printer is uni-code enabled.
    2) Make sure, your unicode enabled printer is configured in SAP.
    3) make sure, your printer device is supported by SAP. (You can find list of SAP recommended printers in www.service.sap.com)
    4) Check whether the correct device type is used for printing chinese and japanese characters.
    5) Check code pages.
    6) Make sure you use Cyrillic font family, for printing chinese and Japanese characters.
    Regards,
    SaiRam

  • Converting garbled characters for JAPANESE characters in a custom table

    Hi all,
    I have a custom table that store Japanese characters.
    After my company has upgraded to ECC6.0, this data in the custom table has become garbled and its alot of it garbled.
    Is there any SAP tool that can I use to make the correction on those garbled Japanese characters?
    Thanks,
    William Wilstroth

    Hi Nils,
    I really really really had a field day reading and testing around UC... To my dissappointment, I do not have the authorization to use SUMG and SCP too as well as a few of the TCODES...
    I finally told my higher level technical mgnt. that this table might need some changes...
    Has this problem of mine got anything to do with MDMP since its no longer supported in ECC6 and I found one coding that search for MDMP in RSVTPROT...
    My colleagues suggest that the data be corrected from table DBTABLOG... which i find, in my opinion, is not the right way...
    Thanks,
    William

  • Creating a PDF from a SAAS app creates boxes instead of Japanese characters

    I'm using an online app (Unleashed Software) to "print" invoices, and the printed invoices show boxes instead of Japanese characters. The really weird thing about this problem, is that it occurs only on certain devices. I've tested on Macs, Windows, Android, and iOS, and on some devices I get the problem, and on some devices I don't. It's not just a Windows problem, or a iOS problem. Additionally, I use different browsers, from Chrome, to IE, to Firefox, to Safari. Changing the browser doesn't seem to help when it's on a device that won't output Japanese characters in a PDF properly.
    I'm wondering how PDFs are generated when using online software. Since I can't reproduce the problem on certain devices, it seems to me that the software is using some local settings to render the PDF incorrectly.
    Any ideas of how I could go about troubleshooting this problem?

    Hi,
    Could you please answer the following questions
    1.What version of Crystal Reports are you using?
    Go to Help-> About to find out.
    2.What is the font you are using on the report?
    Try to change the font style to MS Gothic or Arial Unicode MS, most preferably MS Gothic.
    And export the report to PDF format.
    This may help you
    Thanks,
    Praveen G

  • Saving a file in a with a file name containing Japanese Characters

    Hi,
    I hope some genius out there comes up with the solution to this problem
    Here it is :
    I am trying to save some files using a java program from the command console , and the file name contains japanese characters. The file names are available to me as string values from an InputStream. When I try to write to a File Object containing the japanese characters , I get something like ?????.txt . I found out that I am able to save the files using the unicode value of the java characters.
    So I realize that the trick is to convert the streaming japanese characters , character by character into their respective unicode value and then Create A File Object with that name. The problem is -> I cant find any standard method to convert these characters into their unicode values. Does anyone have a better solution ? Remember , its not writing japanese characters to a file , but creating a file with japanese characters in the file name !!!!
    Regards
    Chandu

    retrive a byte array out of the input Stream and store the values in String using the condtructor
    String(byte [] bytes, String enc)
    where encoding would be Shift_Jis for japanese I guess.
    Now to understand this concept basically all the Strings are unicode however when you are passing a byte array String has no means to know what is the encoding of the byte array, which is being used to instantiate the String value so if no encoding is specified it takes the System value which is mostly iso-8859-1. This leads to displaying ?
    However in case you know the encoding of the array specifying that in the constructor would be a real help.

  • Japanese characters display with wrong encoding all of a sudden...

    I had no issues before when it came to typing in Japanese in DW using the windows language bar , I would just change the keyboard to JP(japanese) and then start typing within DW code view, but then one day after doing updating my main template and using the find and replace feature in DW all the Japanese characters turned into question marks, diamonds with question marks and ASCII alphanumeric codes..
    also the spaces in my documents  turned into blocks. It was a mess,
    *I don't know if it was something I triggered accidentaly or if it was some type of bug....I also remember copying and pasting text and Japanese characters from another website that I created(but I had done that a dozen times before and it was never a problem).
    Long story short, after not being able to find a solution I decided to manually delete the weird symbols and start over, I typed in Japanese using the windows language bar as always and began typing away inside the same pages that displayed those weird characters (sorry I don't know what the proper name for them is)and it accepted the Japanese characters with no issues, it was working just like it did before.
    but my question is "What happened?" was that a bug in DW or was it something on my end?
    I would like to know so I can fix the problem incase this happens again.
    I've always had utf-8 as the charset and it's never been an issue. (and I all my pages are saved as utf-8 as well)
    --Which is why I am confused why all the Japanese got messed up.
    Here is the head code of one of the pages that had the problem:
    Thank you.

    Without seeing an actual page, it's impossible to say what happened, but the most likely explanation is that you did something wrong. Asian characters, such as Japanese, require correct encoding. If the encoding is incorrect, you end up with mojibake.
    I suspect that what happened is that you copied and pasted from Shift-JIS or EUC-JP encoding into a different encoding. It's quite possible that your page was set to iso-8859-1 (Western European) without realizing.
    By the way, your head code didn't show up in your post.

  • Chinese/Japanese characters not appearing on smartforms PDF output

    Hi,
    The print preview of the Smartforms output layout is correctly displaying the characters of native/local languages like Chinese, Japanses etc.....but when i try to print this output, it is printing the junk characters.
    Whereas the same printer is able to print the Chinese, Japanese characters when printed from MS Word.
    So this issue is occurring only when printing from SAP.
    In spool i could see the Chinese/Japanese characters appearing correctly, whereas when i try to convert it to PDF using program RSTXPDFT4, the PDF is again showing junk characters replacing the chinese characters.
    Thanks!

    This could be of different reeasons...
    1) Make sure your printer is uni-code enabled.
    2) Make sure, your unicode enabled printer is configured in SAP.
    3) make sure, your printer device is supported by SAP. (You can find list of SAP recommended printers in www.service.sap.com)
    4) Check whether the correct device type is used for printing chinese and japanese characters.
    5) Check code pages.
    6) Make sure you use Cyrillic font family, for printing chinese and Japanese characters.
    Regards,
    SaiRam

  • Square boxes instead of Japanese characters in pdf output of a crystal rep

    Hi All,
    Did anyone of you ever faced such an issue, where the pdf output of a crystal report shows square boxes instead of Japanese characters when the output is saved in pdf. However the crystal report output looks perfect. I have saved the ouput in xls and rtf formats the characters look perfect as required, the issue we have is when the output is saved as pdf.
    I have language pack installed on my machine.
    My guess is that the few Character's width is not sufficient and few Characters in other fields appear perfect in pdf. I have to test this, it might take few days before I can access this report. Before that I want to gather information. If anyone has solution to this issue please let me know.
    Thanks,
    Ravi

    Hi,
    Could you please answer the following questions
    1.What version of Crystal Reports are you using?
    Go to Help-> About to find out.
    2.What is the font you are using on the report?
    Try to change the font style to MS Gothic or Arial Unicode MS, most preferably MS Gothic.
    And export the report to PDF format.
    This may help you
    Thanks,
    Praveen G

  • Can't input Japanese characters into BrowserBasedHelp search

    We're using RH 8.0.2.208 to create BrowserBasedHelp output for a client-side application. We have a different project for each language. In the Japanese language output, a user cannot enter Japanese characters into the search field using the Japanese keyboard; when you press the keys, nothing displays in the search field, but you CAN copy and paste Japanese characters into the search field and find results.
    The Project Settings: Language setting is set to Japanese (Japan), and the properties in the generated HTML topic files are also set for Japanese.
    Has anyone run into this before? I've searched and found a few topics with similar problems, but didn't see any replies or answers.

    Hi,
    I dont have japanese keyboard, but I tried the same with Japanese langauge bar installed with Microsoft IME. And I was able to type japanese characters in Browser based help.
    thanks
    Praful

  • [Bug Report] CR4E V2: Exported PDF displays Japanese characters incorrectly

    We now plan to transport a legacy application from VB to Java with Crystal Reports for Eclipse. It is required to export report as PDF file, but result PDFs display Japanese characters incorrectly for field with some mostly used Japanese fonts (MS Gothic & Mincho).
    Here is our sample Crystal Reports project:   [download related resources here|http://sites.google.com/site/cr4eexportpdf/example-of-cr4e-export-pdf]
    1. PDFExportSample.rpt located under ..\src contains fields with different Japanese fonts.
    2. Run SampleViewerFrameClient#main(..) to open a Java Report Viewer:
        a) At zoom rate 100%, everything is ok.
        b) Change zoom rate to 200% or 50%, some fields in Japanese font collapse.
        c) Export to PDF file,
             * Fonts "MS Gothic & Mincho": both ASCII & Japanese characters failed.
             * Fonts "Meiryo & HGKyokashotai": everything works well.
             * Open PDF properties, you will see all fonts are embedded with built-in encoding.
             * Interest to note that copy collapsed Japanese characters from Acrobat Reader, then
               paste them into a Notepad window, Notepad will show the correct Japanese characters anyway.
               It seems PDF export in CR4E mistaking to choose right typeface for Japanese characters
               from some TTF file.
    3. Open PDFExportSample.rpt in Crystal Report 2008 Designer (trial version), and export it as PDF.
        The result PDF displays both ASCII & Japanese characters without any problem.
    Test environment as below:
    * Windows XP Professional SP3 (Japanese) with MS Office which including extra fonts (i.e. HGKyokashotai)
    * Font version: MS Gothic, Mincho, Meiryo, all in Version 5.0
        You can download MS Meiryo from Microsoft's Site:
        http://www.microsoft.com/downloads/details.aspx?familyid=F7D758D2-46FF-4C55-92F2-69AE834AC928&displaylang=en)
    * Eclipse 3.5.2
    * Crystal Reports for Eclipse, V2, 12.2.207.r916
    Can this problem be fixed? If yes how long will it take to release a patch?
    We really looking forward to a solution before abandoning CR4E.
    Thanks for any reply.

    I have created a [simple PDF file|http://sites.google.com/site/cr4eexportpdf/inside-the-pdf/simple.pdf?attredirects=0&d=1] exported from CR4E. It is expected to display "漢字" (or in unicode as "\u6F22\u5B57"), but instead being rendered in different ones of "殱塸" (in unicode as "\u6BB1\u5878").
    Look inside into this simple PDF file (you can just open it with your favorite text editor), here is its page content:
    8 0 obj
    <</Filter [ /FlateDecode ] /Length 120>>
    stream ... endstream
    endobj
    Decode this stream, we get:
    /DeviceRGB cs
    /DeviceRGB CS
    q
    1 0 0 1 0 841.7 cm
    13 -13 569.2 -815.7  re W n
    BT
    1 0 0 1 25.75 -105.6 Tm     <-- text position
    0 Tr
    /ttf0 10 Tf                 <-- apply font
    0 0 0 sc
    ( !)Tj                      <-- show glyphs [20, 21], which index is to embedded TrueType font subset
    ET
    Q
    The only embeded font subset is defined as:
    9 0 obj /ttf0 endobj
    10 0 obj /AAAAAA+MSGothic endobj
    11 0 obj
    << /BaseFont /AAAAAA+MSGothic
    /FirstChar 32
    /FontDescriptor 13 0 R
    /LastChar 33
    /Subtype /TrueType
    /ToUnicode 18 0 R                            <-- point to a CMap object
    /Type /Font
    /Widths 17 0 R >>
    endobj
    12 0 obj [ 0 -140 1000 859 ] endobj
    13 0 obj
    << /Ascent 860
    /CapHeight 1001
    /Descent -141
    /Flags 4
    /FontBBox 12 0 R
    /FontFile2 14 0 R                            <-- point to an embedded TrueType font subset
    /FontName /AAAAAA+MSGothic
    /ItalicAngle 0
    /MissingWidth 1000
    /StemV 0
    /Type /FontDescriptor >>
    endobj
    The CMap object after decoded is:
    18 0 obj
    /CIDInit /ProcSet findresource begin 12 dict begin begincmap /CIDSystemInfo <<
    /Registry (AAAAAB+MSGothic) /Ordering (UCS) /Supplement 0 >> def
    /CMapName /AAAAAB+MSGothic def
    1 begincodespacerange <20> <21> endcodespacerange
    2 beginbfrange
    <20> <20> <6f22>                         <-- "u6F22"
    <21> <21> <5b57>                         <-- "u5B57"
    endbfrange
    endcmap CMapName currentdict /CMap defineresource pop end end
    endobj
    I can write out the embedded TrueType font subset (= "14 0 obj") to a file named "[embedded.ttc|http://sites.google.com/site/cr4eexportpdf/inside-the-pdf/embedded.ttf?attredirects=0&d=1]", which is really a tiny TrueType font file containing only the wrong typefaces for "漢" & "字". It seems everything OK except CR4E failed to choose right typefaces from the TrueType file (msgothic.ttc).
    Is it any help? I am looking forward to any solution.

  • ITunes extracted album art file name oddity (Japanese characters)

    I am on iTunes 10.6.3. After doing a clean install of Mountain Lion I have noticed that although the iTunes version has not changed some behavior is slightly different than when it was running under Snow Leopard.
    Any time I drag album art from an album titled with Japanese characters out of the "Now Playing" pane in the lower left of the iTunes GUI the image file in Finder has been named with weird characters. I can successfully rename the file in Finder with the proper Japanese characters. Why is iTunes naming the image files incorrectly?
    Here is an example of an album art image file both as it came from iTunes and after being renamed. The top one is the incorrectly titled file that came straight from iTunes.

    Try this...
    btabz: My songs have artwork in iTunes, but it won't transfer to my iPod!
    It is for a slightly different issue, but the instructions should work.
    If those don't work, you may need to restore the iPod as the link says.
    btabz

  • Create HTML file that can display unicode (japanese) characters

    Hi,
    Product:           Java Web Application
    Operating system:     Windows NT/2000 server, Linux, FreeBSD
    Web Server:          IIS, Apache etc
    Application server:     Tomcat 3.2.4, JRun, WebLogic etc
    Database server:     MySQL 3.23.49, MS-SQL, Oracle etc
    Java Architecture:     JSP (presentation) + Java Bean (Business logic)
    Language:          English, Japanese, chinese, italian, arabic etc
    Through our java application we need to create HTML files that have to display unicode text. Our present works well with English and most of the european character set. But when we tried to create HTML files that will display unidoce text, say japanese, only ???? is getting displayed. Following is the code we have used. The out on the browser displays the japanese characters correctly. But the created file displays only ??? in place of japanese chars. Can anybody tell how can we do it?
    <%
    String s = request.getParameter( "txt1" );
    out.println("Orignial Text " + s);
    //for html output
    String f_str_content="";
    f_str_content = f_str_content +"<HTML><HEAD>";
    f_str_content = f_str_content +"<META content=\"text/html; charset=utf-8\" http-equiv=Content-Type></HEAD>";
    f_str_content = f_str_content +"<BODY> ";
    f_str_content = f_str_content +s;
    f_str_content = f_str_content +"</BODY></HTML>";
    f_str_content = new String(f_str_content.getBytes("8859_9"),"Shift_JIS");
    out.println("file = " + f_str_content);
              byte f_arr_c_buffer1[] = new byte[f_str_content.length()];
    f_str_content.getBytes(0,f_str_content.length(),f_arr_c_buffer1,0);
              f_arr_c_buffer1 = f_str_content.getBytes();
    FileOutputStream l_obj_fout; //file object
    //file object for html file
    File l_obj_f5 = new File("jap127.html");
    if(l_obj_f5.exists()) //for dir check
    l_obj_f5.delete();
    l_obj_f5.createNewFile();
    l_obj_fout = new FileOutputStream(l_obj_f5); //file output stream for writing
    for(int i = 0;i<f_arr_c_buffer1.length;i++ ) //for writing
    l_obj_fout.write(f_arr_c_buffer1);
    l_obj_fout.close();
    %>
    thanx.

    Try changing the charset attribute within the META tag from 'utf-8' to 'SHIFT_JIS' or 'utf-16'. One of those two ought to do the trick for you.
    Hope that helps,
    Martin Hughes

Maybe you are looking for