Is a way to find out the encoding of a String?

Doesn anyone know how to find out the encoding?

There are some circumstances in which a file (or more
generally, a stream) may expose its own encoding,
IIRC. But of course that's the exception, not the rule.As part of a higher level protocol, sure. HTTP, for example, may have it in a couple places (headers or in the HTML head section). Plain text files do not, however.
But anyway at this point I'm not convinced that
anyone knows for sure what the OP wanted or needed.I agree with that. Not convinced the OP knows, either.
Was he really looking for a heuristic to correctly
y guess the encoding of a stream of bytes, so that
encoding could be used as input to a String
constructor? Or did he just not know how to use the
API?To the OP:
If you have a String, there's no encoding, it's all Unicode chars in the string.
If you have a bunch of bytes (byte[], file, input stream, whatever), then there is some encoding. If you don't know what the encoding is, there's no 100% sure way to figure it out. Some code exists, as mentioned, that can make educated guesses, particularly if you know it's one of a few possible choices. Beyond that, bytes are bytes are bytes, and how they are interpreted by character based classes/methods (like new String(byte[], String)) is defined by the encoding you tell it to use.
So aside from that, what's the issue you're trying to solve?

Similar Messages

  • How to find out the encoding of an XML input document

    Hello all,
    I read a XML file into a DOM document and would like to save it back in the same encoding as the input. How do I find out the encoding of the input document?
    This is my code for reading the document:
    import java.io.File;
    import java.io.FileInputStream;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMResult;
    import javax.xml.transform.stream.StreamSource;
    import org.w3c.dom.Document;
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    DOMResult domResult = new DOMResult();
    transformer.transform(new StreamSource(new FileInputStream(fileName)),
                          domResult);
    Document doc = (Document)domResult.getNode();
    .

    FileInputStream fis = new FileInputStream(fileName);
    String encoding = new InputSource(fis).getEncoding();
    fis.close();Note that this only works because you can get an InputStream over the document twice. If the document were coming from an HTTP response (for example) it wouldn't work.

  • Looking for a way to find out the x,y coordinates of a string inside a PDF

    Hi!
    I'm looking for a way to find out the x,y coordinates of a string inside a PDF (with free java api's only)
    I got a pdf, and a string to find inside it, what i need to do is to get this string x,y position inside that pdf....
    If any one knows of such, plz let me know...
    Thanx ahead
    Daniel.

    vedmack wrote:
    Hi!
    I'm looking for a way to find out the x,y coordinates of a string inside a PDF (with free java api's only)
    I got a pdf, and a string to find inside it, what i need to do is to get this string x,y position inside that pdf....
    If any one knows of such, plz let me know...
    Thanx ahead
    Daniel.AFAIK, a string of text does not have an (x,y) location inside a PDF file. The location is exists on your screen, and will differ whenever you adjust the resolution of it. Text can have a location when it's stored as an image though, but than it's really the location of a certain number of pixels (not necessarily a string!).

  • Is there a way to find out the GUI version of a logged in user

    Hello all,
    SAP provides a method in CL_GUI_FRONT_END_SERVICES called GET_GUI_VERSION. This works fine for supplying the version information for the logged in user.
    Unfortunately, it doesn't have any input parameters to specify "ANY"  user name.
    I'm looking for a way to find out the gui version of all logged in users.
    Tables USR41 will give me a list of the logged in users
    I can then use USR21, ADR6 and ADRP to get more user info.
    But, I can't find a way to determine what GUI version each of the users is using.
    Does anyone have any ideas?
    Thanks
    Ed Baker

    We have done in a different way. ie we have used userexit SUSR0001 and coded using
    * Collect SAPGUI info of the user logging on
    call function 'RFC_SYSTEM_INFO' destination 'SAPGUI'
      importing
        rfcsi_export = i_rfcsi.
    Here i_rfcsi-rfcsaprl contains the version info of SAPGUI
    and updated this info in a custom table.

  • Is there any way to find out the serial number to an old ipod that i cannot find?

    theres a recall on the od ipod nanos the 1st generation ones and i purchased one and im not sure when and currently i am unaware of the whereabouts of the ipod. is there any way to find out the serial number without actually finding the ipod to confirm when i purchased it? thank you any help will be appreciated.

    iPod: How to find the serial number

  • Is there a way to find out the given parameter is statis or Dynamic ?

    Hi All,
    Can some one tell me the best way to find out the given parameter is static or Dynamic?
    Thanks & Regards
    Rajesh Meda

    Well, Actually  I know there is a way for checking from RZ11 transaction.
    1.I need to prepare report with all the ABAP parameters  in the system that can be changed on fly
    2.I believe there is one ABAP report that will specify all the dynamic parameters. I need the report name
    Thanks & Regards
    Rajesh Meda

  • Is there a way to find out the number of hits from iTunes for my podcast?

    Looking over my stats pages I see that 95% of all people listening to my podcast are coming from iTunes mac/windows. I suppose I could do the math, but i'm curious if there is a way to find out the exact number of people subscribed to the podcast in iTunes?
    Eric
    www.letsgetnaughtypodcast.com

    hi there you can use http://www.statcountercom
    this will give you a way to see exactly where everyone is from. just install the code it make and put it in your podcast page. and everytime some one come to the podcast you will find your info
    http://www.radioamerica1.com
    http://radioamerica.podomatic.com
    http://backalleyblues.podomatic.com
    here a few of my podcast that i have , hope this helped also

  • Is there any way to find out the dependency information for column of view?

    Does Oracle provide some view / table / pl/sql pkgs to find out the dependency information for column of view ?
    For example, there are two table mytable1 (col1 varchar2(10), col2 date) & mytable2 (col1 varchar2(10), qty int), and there is one view myView as
    select mytable1.col1, col2, qty from mytable1 inner join mytable2 on mytable1.col1 = mytable2.col
    Can I get some information such as myView.col1 is come from mytable1.col, myView.col2 is come from mytable1.col2, myView.qty is come from mytable2.qty
    ?

    I can get the information about the columns list in table/view from ALL_TAB_COLUMNS table, but I wish to know the column in the view is come from which original table's column.
    Is there any way to find it out from Oracle meta data / through any PL/SQL packages ?

  • I just got a text from verizon stating  a 3rd party vendor just charged to my bill.  Is there a way to find out the cost of the charge.

    Is there a way to find out what a 3rd party vendor charged to my bill, before the end of the billing cycle.

    You could try calling CS, but other than that I don't think there is.

  • Is there a way to find out the caller function in ESTK?

    Dear forum,
    How do you find out the caller function?
    I remember this question was asked on the forum before and, if memory serves me right, it was Peter Kahrel who answered it. Anyway, it was long ago and I can't find the post.
    main();
    function main() {
        hello();
    function hello() {
        // Is it possible to find out that the caller function is 'main'?
    Before making the post, I googled for it and found many suggestions, for example:
    alert("caller is " + arguments.callee.caller.toString());
    But nothing works for me.
    Regards,
    Kasyan

    Here's a new version of the function:
    function callerName() {
        var arr = $.stack.split(/[\n]/),
        callerName = arr[arr.length - 3].replace(/\(.*\)/, "")
        return callerName;
    I corrected the regex to remove the parentheses and everything in between.
    The previous version returned the function's name with arguments, like so:
    Result: ProcessTables([Paragraph:[object Paragraph]])

  • Any specific way to find out the tables being affected by a FormHandler

    Please let me know an approach I can follow to find out the tables being affected on calling a particular Formhandler.

    In our custom implementation, the basic work of a formhandler is to validatate data that came from a form. In our formhandler, we use some manager class and from manager class we call some tool class. In our tool class we will use some repository(In a repository we give definitionFiles=......../xyz.xml). So what operation we are going to perform via form like add, update, delete, show will affect tables in xyz.xml file.
    In OOTB supost we are using ProfileFormHandler so it will affect ProfileAdapterRepository, which has xml file is useProfile.xml.
    -RMishra

  • How to use statement "search" to find out the asterisk in a string?

    Hi Guys,
       I encouter this question:I need to use "search" statement to find out the asterisk or the underscore in one string,you know these two symbols are wildcards. I don't know how to use statement "search" to find them??
       could you please give me some help!!
    Thanks a lot,Villy.Lv
    Edited by: Villy Lv on Sep 26, 2010 6:50 AM

    Hi,
    You cant usesearch statement, rather did you try with CS using IF condition? even you can go with loop statement too.
    DATA STRING TYPE STRING.
    DATA C TYPE C.
    DATA LEN TYPE I VALUE 0.
    DATA I TYPE I VALUE 0.
    LEN = STRLEN(STRING).
    LOOP LEN > I
         C = STRING+I.
         IF(C == '*' OR C == '_').
         ENDIF.
         I = I + 1.
    ENDLOOP.
    This way also you can use.
    Hope this may help you.
    Regards!
    Sheik

  • Any way to find out the serial number of the iPod I registered?

    My iPod was stolen a couple of days ago, and I need to find out what the serial number was (I registered it, but didn't write it down). Is there any way to get the serial # from Apple?
    iPod Nano   Windows XP  

    If you still have the box for the iPod it should say it on there...
    http://docs.info.apple.com/article.html?artnum=60978#four
    Hope This Helps
    CG

  • Best way to find out the applications/packages on the Sun Servers

    I need to find out what applications or packages are running on 10+ Sun Solaris servers, and the dependence.
    I am wondering what is the best practice to do this?

    Are you asking about what you see when you type "ps -ef" to see the processes? Or are you maybe also referring to what applications might be installed on your system for use? "pkginfo" lists all packages that are installed on the system, and you can go to the sysadm documentation on docs.sun.com to see a brief description of each of the packages.
    -- Alan

  • What is the best way to find out the underlying platform within AIR?

    I'd like to know whether Air is running on iOS, Windows, Android or Blackberry.

    Here's our Utuls_System class. It's a work in progress, incomplete, and does other stuff as well, but take a look at init() and isIOS() etc...
    package com.brightworks.util
        import com.langcollab.languagementor.constant.Constant_AppConfiguration;
        import flash.system.Capabilities;
        public class Utils_System
            public static const OS_CATEGORY__ANDROID:String = "osCategory_Android";
            public static const OS_CATEGORY__IOS:String = "osCategory_iOS";
            public static const OS_CATEGORY__MAC:String = "osCategory_Mac";
            public static const OS_CATEGORY__UNKNOWN:String = "osCategory_Unknown";
            public static const OS_CATEGORY__WINDOWS_DESKTOP:String = "osCategory_WindowsDesktop";
            public static const OS_CATEGORY__WINDOWS_MOBILE:String = "osCategory_WindowsMobile";
            private static var _isInitialized:Boolean;
            private static var _isMobileDevice:Boolean;
            //          Getters / Setters
            private static var _appHeight:int;
            public static function get appHeight():int
                init();
                return _appHeight;
            private static var _appWidth:int;
            public static function get appWidth():int
                init();
                return _appWidth;
            private static var _dpi:int;
            public static function get dpi():int
                init();
                return _dpi;
            private static var _osCategory:String;
            public static function get osCategory():String
                return _osCategory;
            //          Public Methods
            public static function getAppStoreName():String
                if (isIOS())
                    return "Play Store";
                return "App Store";
            public static function isIOS():Boolean
                return (osCategory == OS_CATEGORY__IOS);
            public static function isScreenResolutionHighEnough(requiredX:uint, requiredY:uint, isMobile:Boolean):Boolean
                init();
                if ((isMobile) && (!Utils_System._isMobileDevice))
                    // We're testing on the desktop, and can't check screen size
                    return true;
                if (Capabilities.screenResolutionX < requiredX)
                    return false;
                if (Capabilities.screenResolutionY < requiredY)
                    return false;
                return true;
            public static function isRunningOnDesktop():Boolean
                init();
                return !_isMobileDevice;
            //          Private Methods
            private static function init():void
                if (_isInitialized)
                    return;
                _isInitialized = true;
                _isMobileDevice = true;
                var operatingSystem:String = Capabilities.os;
                if (operatingSystem.indexOf("Windows") != -1)
                    switch (operatingSystem)
                        case "Windows XP":
                        case "Windows 2000":
                        case "Windows NT":
                        case "Windows 7":
                            _isMobileDevice = false;
                            _osCategory = OS_CATEGORY__WINDOWS_DESKTOP;
                            break;
                        default:
                            _osCategory = OS_CATEGORY__UNKNOWN;
                            Log.fatal(Constant_AppConfiguration.APP_NAME + " does not currently support this operating system. (" + operatingSystem + ")");
                else if (operatingSystem.indexOf("iPhone") != -1)
                    _isMobileDevice = true;
                    _osCategory = OS_CATEGORY__IOS;
                else if (operatingSystem.indexOf("MacOS") != -1)
                    _isMobileDevice = false;
                    _osCategory = OS_CATEGORY__MAC;
                else if (operatingSystem.indexOf("Linux") != -1)
                    // This won't work properly if developing on Linux, but I've spent multiple minutes
                    // trying to find out how to differentiate Android from other Linux versions, and
                    // haven't found anything that I'm confident will work for future versions of Android.
                    // Currently I get "Linux 2.6.32.9-g34b306d". I suspect that the "g" indicates "Google"
                    // but have found nothing to support this idea.
                    _isMobileDevice = true;
                    _osCategory = OS_CATEGORY__ANDROID;
                if (_isMobileDevice)
                    _appHeight = Capabilities.screenResolutionY;
                    _appWidth = Capabilities.screenResolutionX;
                else
                    _appHeight = 220;
                    _appWidth = 360;
                _dpi = Capabilities.screenDPI;

Maybe you are looking for

  • Installation problem of ISSUE_TRACKER_1.6 on Oracle Express XE

    Sorry, but I'm new to HTMLDB, and have seen similar problems listed on the forum, but they have not given me insight into my problem. I am running Oracle XE beta on Windows. I only have one workspace and user at the moment. I imported the application

  • No sound on my purchase music

    i had downloaded some songs on october 24 around that week also an app and it was done downloaded but there no sound all of them and we spend 24 $ with the itunes cards. i tryed to report it and it downloaded again but there still no sound

  • Deferred payment terms and Tax due immediatly

    Hi, We would like to know if there is a workaround in SAP to post the customers invoices tax amount with a different due date of the deferred payments. The deferred payments amount will not include tax. What we would like to do according to our busin

  • HT1386 my iphone says " 33 items could not be synced, see itunes for more information" , where is this information?

    I have been syncing my music from my laptop to iphone, no problem until now, a message says " 33 items could not be synced, see itunes for more information", can't find any information that helps me, so, how do I sync these 33 items?  help

  • Not sure I am having StringIndexOutOfBondException

    Hi Fox! I am trying to write a simle code. In my Code I just copy values from Stringbuffer to String. Then delete everything from Stringbuffer and use String in the next block of code. I am not sure why I am having StringIndexOutOfBondException. What