How to get the size of a string in bytes

Morning,
I’m trying to get the length in bytes of a string, the characters below are 3 byte UTF-8, but when I display
The length of either int, looks like is double I got 120 and I think it should be 60. Any idea
String requiredMsg = "όόόόόόόόόόόόόόόόόόόό";
int byteCountUTF8 = requiredMsg.getBytes("UTF-8").length;
int byteCountUTF8 = requiredMsg.getBytes().length;
thanks

OK, it is not 'o with acute', but rather 'Greek small omicron with tonos'.
This page may help you sort it out:http://www.fileformat.info/info/unicode/char/3cc/index.htm.
According to the page and to my tests, this Unicode 03CC has a 2 bytes (not 3) UTF-8 representation.
String requiredMsg = "\u03CC";
System.out.println(requiredMsg.getBytes("UTF-16").length);
System.out.println(requiredMsg.getBytes("UTF-8").length);
System.out.println(requiredMsg.getBytes().length); // In WindowsResult on my machine:
4
2
1

Similar Messages

  • How to get the size of driver[C: or D:]

    Hi Friends,
    I have a query regarding to java..
    I want to get the name of all the drives that r connected to the System including network drives...
    and how to get the size of any system drive[For example C: or D: Drive].
    I want the output to be displayed like in the following format
    Device type size free Usage_Space
    for ex.
    C: NTFS 37.5Gb 30.5gb 7gb
    Output like as linux command df -h
    Edited by: KituPrash on Mar 4, 2009 3:29 AM

    Does this help for starters?
    File[] roots= File.listRoots();
    for (int i= 0; i< roots.length; i++)
         System.out.println(roots[i]+": "+roots.getTotalSpace());kind regards,
    Jos                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to get the size of physical memory by using system call ?

    how to get the size of physical memory by using system call ?What system call can be used for me to get the size of physical memor? thanks.

    %vmstat 3
    procs memory page disk faults cpu
    r b w swap free re mf pi po fr de sr s0 -- -- -- in sy cs us sy id
    0 0 0 3025816 994456 4 19 6 0 0 0 0 8 0 0 0 459 253 139 1 1 99
    0 0 0 2864688 777408 0 2 0 0 0 0 0 3 0 0 0 428 134 175 0 1 99
    0 0 0 2864688 777408 0 0 0 0 0 0 0 7 0 0 0 448 112 166 0 0 100
    one interesting observation about vmstat I found out is (mostly on Solaris)
    the first line of information always off chart, so I usually do a few interval to get constant result.
    if you use linux
    just
    cat /proc/meminfo

  • How to get the size of partition?

    The following SQL will get the rows of the fact table & aggregation. But how to get the size (MB) of the partition. select * from $system.discover_partition_stat That should be doable, because in BIDS, we can see the size of a partition, but from which
    view we can do that?

    This is the best bet you have SELECT * FROM SystemRestrictSchema($system.discover_partition_stat ,DATABASE_NAME = 'Adventure Works DW' ,CUBE_NAME = 'Adventure Works' ,MEASURE_GROUP_NAME = 'Internet Sales' ,PARTITION_NAME = 'Internet_Sales_2003') Refer
    this article: http://geekswithblogs.net/darrengosbell/archive/2008/12/02/ssas-are-my-aggregations-processed.aspxvinu

  • How to get the size of the webpage?

    I am designing a program to
    analyse the webpage content.
    wondering how to get the size of
    the webpage including its image's
    size and etc. Thanks in advance.

    As i know , the getContentLength just return
    then number of characters of its HTML code.
    By knowing the length of the HTML code, is
    not possible for me to calculate its download
    time... i wonder is there any way to get the
    total size of the page including its image size,
    applet size, and etc... Thanks : )

  • How to get the size of a hard disk?

    Hi,
    As above, how to get the size of a hard disk by using Java.
    Thanks you!
    Alex

    I would be interested in the answer of this question, too.
    In core Java there is no way to find it out in a platform independent manner because of the hardware abstraction of the VM. So my only idea is to write a native library for doing this and colling it via JNI

  • How to get the size of the table

    Hi All,
    How to get the size of the table in Oracle 10g?
    Is there any script which needs to be run?
    Regards,
    Apoorv

    Hi All,
    Sorry but somehow the table user_segments is not populated in my case. But we have another table SYS.ALL_TABLES whose structure is given below. Would I be able to calculate the table size based on the columns given below:
    ColumnName     Data Type
    OWNER     VARCHAR2 (30 Byte)
    TABLE_NAME     VARCHAR2 (30 Byte)
    TABLESPACE_NAME     VARCHAR2 (30 Byte)
    CLUSTER_NAME     VARCHAR2 (30 Byte)
    IOT_NAME     VARCHAR2 (30 Byte)
    STATUS     VARCHAR2 (8 Byte)
    PCT_FREE     NUMBER
    PCT_USED     NUMBER
    INI_TRANS     NUMBER
    MAX_TRANS     NUMBER
    INITIAL_EXTENT     NUMBER
    NEXT_EXTENT     NUMBER
    MIN_EXTENTS     NUMBER
    MAX_EXTENTS     NUMBER
    PCT_INCREASE     NUMBER
    FREELISTS     NUMBER
    FREELIST_GROUPS     NUMBER
    LOGGING     VARCHAR2 (3 Byte)
    BACKED_UP     VARCHAR2 (1 Byte)
    NUM_ROWS     NUMBER
    BLOCKS     NUMBER
    EMPTY_BLOCKS     NUMBER
    AVG_SPACE     NUMBER
    CHAIN_CNT     NUMBER
    AVG_ROW_LEN     NUMBER
    AVG_SPACE_FREELIST_BLOCKS     NUMBER
    NUM_FREELIST_BLOCKS     NUMBER
    DEGREE     VARCHAR2 (10 Byte)
    INSTANCES     VARCHAR2 (10 Byte)
    CACHE     VARCHAR2 (5 Byte)
    TABLE_LOCK     VARCHAR2 (8 Byte)
    SAMPLE_SIZE     NUMBER
    LAST_ANALYZED     DATE
    PARTITIONED     VARCHAR2 (3 Byte)
    IOT_TYPE     VARCHAR2 (12 Byte)
    TEMPORARY     VARCHAR2 (1 Byte)
    SECONDARY     VARCHAR2 (1 Byte)
    NESTED     VARCHAR2 (3 Byte)
    BUFFER_POOL     VARCHAR2 (7 Byte)
    ROW_MOVEMENT     VARCHAR2 (8 Byte)
    GLOBAL_STATS     VARCHAR2 (3 Byte)
    USER_STATS     VARCHAR2 (3 Byte)
    DURATION     VARCHAR2 (15 Byte)
    SKIP_CORRUPT     VARCHAR2 (8 Byte)
    MONITORING     VARCHAR2 (3 Byte)
    CLUSTER_OWNER     VARCHAR2 (30 Byte)
    DEPENDENCIES     VARCHAR2 (8 Byte)
    COMPRESSION     VARCHAR2 (8 Byte)
    DROPPED     VARCHAR2 (3 Byte)

  • How to measure the size of a string

    windows app store how to measure the size of a string?
    string str = "Hello word windows app store";

    if you need the actual width the string occupies in pixels than use (see
    this MSDN link for more details):
    Graphics.MeasureString(String, Font)
    if you only need the "length" of the string i.e. no. of characters than use (see
    this MSDN link for more details):
    str.Length
    dont forget to bing / google :)
    hope this helps!
    Graphics.MeasureString(String, Font) can not use in windows store app.
    TextBlock has Measure()
    method, as following:
    Size MeasureString(string content, Size availableSize, double fontSize, string fontFamily="Segoe UI")
        TextBlock tb = new TextBlock();
        tb.TextWrapping = TextWrapping.Wrap;
        tb.Text = content;
        tb.FontFamily = new Windows.UI.Xaml.Media.FontFamily(fontFamily);
        tb.FontSize = fontSize;
        tb.Measure(availableSize);
        return tb.DesiredSize;
    Test:
    string str = "Hello word windows app store";
    Size size = MeasureString(str, new Size(800, 600), 40);

  • How to get the size of the file

    Hi All,
    I want to get the size of the file in terms of bytes. I used the following code it returns the value in long how can get it in bytes
    import java.io.File;
    public class ServerBackupCheck {
         public static void main(String args[]){
              File f = new File("C:/Program Files/Apache Software Foundation/Tomcat 5.5");
              System.out.println(f.isDirectory());
              System.out.println(f.getTotalSpace());
    output:
    true
    20964163584
    regards,
    Maheshwaran Devaraj

    if it is a folder you can use this recursive algorithm
    public static long recurse(File f) throws IOException
              long bytes = 0;
              File files[] = f.listFiles();
              for(int i =0 ;i<files.length;i++)
                   File file = files ;
                   if(file.isFile())
                        FileInputStream fis = new FileInputStream(file);
                        byte[] by = new byte[fis.available()];
                        fis.read(by);
                        bytes = bytes + by.length;
                   if(file.isDirectory())
                        bytes = bytes + recurse(file);
              return bytes;
    System.out.println(recurse(f));  gives you the total bytes....
    Ayberk Cansever ..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to get the viewrow value by string

    Using Jdev11.1.1.5.0-adfbc-ireport3.0.0
    here i'll describe: what i did.
    am using jsff(dynamic region) while hitting the af:tree nodes it will opens. ok fine
    i had somevo with manually wroten query. and query is fine no problem with that
    here i give sample not a original query
    select * from sometable where acctid = :pacctidi drag and drop the pacctid from corresponding execute params vo as selectoncechoice
    static vo
    Data value - account payable , advance
    Data Name - ap,ad
    in that jsff
    *page representation*
    account type :   account payable (ap) - select one choice type
                            advance           (ad) - select one choice type
    like this some select once choice and some inputs.
    Run report - command button
    .jsff code
    <af:selectOneChoice value="#{bindings.ACCT_TYPE.inputValue}"
                              label="Account Type"
                              shortDesc="#{bindings.ACCT_TYPE.hints.tooltip}"
                              id="soc3" required="true"
                              autoSubmit="true"
                              binding="#{backingBeanScope.SUP1040V.soc3}"
                              valuePassThru="true"
                              valueChangeListener="#{backingBeanScope.SUP1040V.ValueChangeListener1}">
            <f:selectItems value="#{bindings.ACCT_TYPE.items}" id="si3"/>
          </af:selectOneChoice>
    <af:commandToolbarButton text="Export in pdf" id="ctb2">
              <af:fileDownloadActionListener method="#{backingBeanScope.SUP1040V.Report}"
                                             />
            </af:commandToolbarButton>.java
         //while hitting the button following logs are appeared i show it as commented format.
        public void Report(FacesContext context, OutputStream out) throws IOException,Exception
                FacesContext ctx = FacesContext.getCurrentInstance();
                HttpServletRequest request =
                    (HttpServletRequest)ctx.getExternalContext().getRequest();
                HttpServletResponse response = 
                    (HttpServletResponse)ctx.getExternalContext().getResponse();
                BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry();
                System.out.println("print binding" +bindings1 );
    //while using sop i get this in my log : :  print binding  ReportsPageFragments_SUP1040VPageDef_WEB_INF_TaskFlows_SUP1040_V_TF_xml_SUP1040_V_TF
                JUCtrlListBinding listBinding1 = (JUCtrlListBinding)bindings1.get("ACCT_TYPE");
                System.out.println("print list bindings" +listBinding1 );
    //while using sop i get this in my log : :  print list  bindings0
                Object selectedValue1 = listBinding1.getSelectedValue();
                System.out.println("print selected value" + selectedValue1);
    //while using sop i get this in my log : :  print selected  valueViewRow [oracle.jbo.Key[AP ]]   
    request.setAttribute("ACCT_TYPE", //here i want the value  "AP" in  String  );
    if i use like this means
    request.setAttribute("ACCT_TYPE", soc1.getValue()  );  i get the index value.
    i need the dataname "ap" so i go above method which say wrotes ...
                request.getRequestDispatcher(response.encodeURL("/sup1040servlet")).forward(request,response);
                System.out.println("hihihihih");
                response.flushBuffer();
                ctx.responseComplete();
        public void ValueChangeListener1(ValueChangeEvent valueChangeEvent) {
            // Add event code here...
            String AcctType = valueChangeEvent.getNewValue().toString();
            System.out.println("AcctType" + AcctType);
            FacesContext contxt = FacesContext.getCurrentInstance();
            valueChangeEvent.getComponent().processUpdates(contxt);
           BindingContainer bindings1 =
           BindingContext.getCurrent().getCurrentBindingsEntry();
           // Get the sepecific list binding
           JUCtrlListBinding listBinding1 =
           (JUCtrlListBinding)bindings1.get("ACCT_TYPE");
           // Get the value which is currently selected
           Object selectedValue1 = listBinding1.getSelectedValue();
           System.out.println(selectedValue1);
        }if i get ap means my report runs. or else it will shows empty page.
    how to get the viewrowimpl class value as string.
    Edited by: ADF7 on Mar 24, 2012 7:27 AM

    ADF7,
    I'm not sure I understand what you are up to.
    As far as I understand you want to get the display value instead of the index
    I use this code
        public void StatusChangedListener(ValueChangeEvent valueChangeEvent)
            BindingContext lBindingContext = BindingContext.getCurrent();
            BindingContainer lBindingContainer = lBindingContext.getCurrentBindingsEntry();
            JUCtrlListBinding list = (JUCtrlListBinding) lBindingContainer.get("Status");
            int newindex = (Integer) valueChangeEvent.getNewValue();
            Object row = list.getDisplayData(); // Wichtig um die liste zu laden!!!!
            Row lFromList = (Row) list.getValueFromList(newindex);
            Object lAttribute = lFromList.getAttribute("Value");
            String newVal = (String) lAttribute;
        }to get the value from a selectOneChoice component...
    Timo

  • How to get the size of the cuurrent illustration

    Sorry, I made a mistake before this one. The questios is this: can anybody tell me how can I get the size of the current illustration, (as oposed to the page size) in points. Something like 120 points wide and 87 points High?. What function do I need to call?

    From AI Function reference (included with CS2 SDK):
    AIDocumentSetup setup;
    error = sDocument->GetDocumentSetup(&setup);
    if (error) goto processError;
    writeDocumentSetup( &setup );
    The AIDocumentSetup record returns the following information:
    typedef struct {
    AIReal width, height;
    AIBoolean showPlacedImages;
    short pageView;
    AIReal outputResolution;
    AIBoolean splitLongPaths;
    AIBoolean useDefaultScreen;
    AIBoolean compatibleGradients;
    AIBoolean printTiles;
    AIBoolean tileFullPages;
    } AIDocumentSetup;

  • How to get the size of the test put in a JPasswordField ?

    I've checked all the methods that may allow me to know the size
    of the text in a JPasswordField.
    I tested getCaretPosition() , getSelectedEnd()
    and they don't satisfy me : they give the current position of the cursor
    and not the size of the text typed. The only safe method is the use
    of the method getText() which is deprecated, so that i can get the
    size of the resulting String.
    Is there a method that allow to know the size of a char arrays ?
    Any help will be welcome, thanks.

    JPasswordFieldObj.getPassword().length;the length variable isn't visible in the forte visual parameters.
    thanks a lot, it saved me a lot of time and let me keep the
    getPassword() secure.
    Sorry, don't have more duke dollars, but you should have get some for this.

  • How to get the size of a file DONE

    How can I get the size a file? I want to do the following....
    File clobDataFile = new File("clob.dat");
    PrintWriter clobpw = new PrintWriter(new BufferedWriter(new FileWriter(clobDataFile)));
    int               offset     = //get the number of chars in the fileOk I am a tard... figured it out...
    File clobDataFile = new File("clob.dat");
    PrintWriter clobpw = new PrintWriter(new BufferedWriter(new FileWriter(clobDataFile)));
    int               offset     =colbDataFile.length();

    read API http://java.sun.com/j2se/1.5.0/docs/api/java/io/File.html#length()
    next time you have a similar question please refer this document

  • How to get the size of file

    Hi
    I want to know the size of the file from Java. ie If i have 10 lines in that file each of 15 characters
    then 10 *2*10=200Bytes is the size. How will i get this?
    More over, if i am reading the 4 the line, how will get the info that I have read 3 lines =3*2*10= 60 bytes so far?
    Regards
    Sriram

    This is from the JavaDocs on java.io.File
    length
    public long length()
    Returns the length of the file denoted by this abstract pathname. The return value is unspecified if this pathname denotes a directory.
    Returns:
    The length, in bytes, of the file denoted by this abstract pathname, or 0L if the file does not exist
    Any of the read methods (except readLine()) on the many stream objects return the number of bytes read, simply accumulate these returns to know how many bytes have been read.
    Dave

  • How to get the system date format string?

    Hello, everybody!
    I want to create a MaskFormatter with a mask for dates. So, I could suply as the constructor parameter: "##/##/####'. However, what if the year comes first in the current system date format settings, or the month is in the second place or in the first?... So, I can't just suppose that the current locale format for dates is like the one above. So, my question is: is there a way to get the SYSTEM DATE FORMAT STRING in Java? Searching in google I saw that this was already asked in this forum:
    http://forum.java.sun.com/thread.jspa?threadID=301034&messageID=1193794
    but there was no effective answer. Does someone already know how to get this?
    Thank you.
    Marcos

    Hi, not sure, but
    import java.text.*;
    SimpleDateFormat sdf = new SimpleDateFormat();
    System.out.println(sdf.toPattern());
    will output something like dd/MM/yy HH:mm
    hthThank you very much. It worked.

Maybe you are looking for

  • TS1567 import pics from pc to iphone 4 s

    hi i am new to iphone, could you please tell me how to import phots and pics from my pc to my iphone 4s

  • Change open item management status

    Hi, We found the some GL accounts are maintained with no open item management status and already have postings in those GL accounts. No, our client is aksing us to rectify the all this kind of accounts with no open item management. Earlier we rectifi

  • Goldengate replicate physical standby database

    Friends, I did not get a answer in data guard place Could we use oracle golden gate  to replicate a data guard  physical standby database into a  new logical database? Or we must replicate data guard primary database into a new logical database? Than

  • Acrobat X: Java-Script-Problem

    Hallo zusammen, ich habe folgendes Problem: aus einer .pdf-Datei möchte ich die Bookmarks, die ich selbst erstellt habe, auslesen (warum führt zu weit). Dafür verwende ich folgendes Script, das ich von www.evermap.com/javascript.asp habe: /* Create a

  • Access to archived email folders

    I use ms exchange for my emails and have archived folders how do I access those folders from my ipad