×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Regular Contributor
    Join Date
    Apr 2010
    Posts
    90

    Lightbulb how we can read a file ?? which is in different language????

    what i will do to read a text of a file which is in another language??

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: how we can read a file ?? which is in different language????

    if you are meaning that the encoding is different, then just read it normally to a buffer and use character converters to convert the encoding.

  3. #3
    Regular Contributor
    Join Date
    Apr 2010
    Posts
    90

    Re: how we can read a file ?? which is in different language????

    any one tell me

    eg: HBufC8* ReadOpenFileL(const TDesC& aFile)

    I want call ReadOpenFileL function like ..In E32Main() to just know how it is working.

    HBufC8 *GetBuf=HBufC8::ReadOpenFileL(aFile);

    now wat to do for GetBuf???

    please tell me how to call and what to do after getting return?? after processing of this function.

  4. #4
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166

    Re: how we can read a file ?? which is in different language????

    you could have a look into RFile API for exmaple.

  5. #5
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: how we can read a file ?? which is in different language????

    When you are referring to a Wiki article feel free to provide its link next time: http://wiki.forum.nokia.com/index.ph..._writing_files
    ReadOpenFileL is not a method of HBufC8, it is just a function, you can put it anywhere and call it whenever you need it. However it expects the presence of CCoeEnv, so it is meant to be used in GUI applications. If you create your own RFs variable and Connect it, you can pass it in place of "CCoeEnv::Static()->FsSession()", and the code will work in console applications too.
    E32Main is not a good place for doing anything, since you have no Cleanup Stack there. That is why a usual non-GUI application simply creates CTrapCleanup in E32Main, then calls some function (MainL by convention) in a TRAP/D.

    Otherwise it tries to Open a file, then checks its Size, creates a New(L) HBufC8 with that size, gets the writable Des-criptor for that HBufC8, Read-s the file content into it, and returns the HBufC8 variable. You can convert it to a 16-bit descriptor using CnvUtfConverter::ConvertToUnicodeFromUtf8L, or via
    Code:
    // HBufC8 *result8=ReadOpenFileL(_L("c:\Data\test.txt"));
    // CleanupStack::PushL(result8);
    HBufC *result16=HBufC::NewLC(result8->Length());
    result16->Des().Copy(*result8);
    Then you can print it for example, if you have a console
    Code:
    console->Printf(_L("File content:\n%S"),result16);

  6. #6
    Regular Contributor
    Join Date
    Apr 2010
    Posts
    90

    Re: how we can read a file ?? which is in different language????

    "CCoeEnv::Static()->FsSession()
    can any one explain it ..according to me FsSession() is the fuction of CCoeEnv Class but sir why through Static() function we are calling?
    i just know function call through object and pointer object but do'nt know function??

    E32Main is not a good place for doing anything, since you have no Cleanup Stack there. That is why a usual non-GUI application simply creates CTrapCleanup in E32Main, then calls some function (MainL by convention) in a TRAP/D.
    Sir then where i should test Symbian Concept and how i can see just out of our tested sample code..

    I used TRAPD() like this ..
    Code:

    GLDEF_C TInt E32Main()
    {
    __UHEAP_MARK;
    CTrapCleanup *cleanupstack=CTrapCleanup::New();
    TRAPD(error,RunConsoleL());
    then in case of
    ReadOpenFileL(_L("c:\Data\test.txt"))
    Can we use TRAPD like this
    TRAPD(error,ReadOpenFileL(_L("c:\Data\test.txt"));

    You can convert it to a 16-bit descriptor using CnvUtfConverter::ConvertToUnicodeFromUtf8L
    here why I need to convert into 16 bit descriptor .can'nt I use direct in 16 bit ..

    and last question is gentelmens ...

    c:\Data\test.txt

    Can I open test.gif file also in same manner


    Thank you very much in Advance
    I'm Very thankfull to that person who make Nokia Forum to help new born ..i'm getting very help to learn symbian Thank you to every one

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,689

    Re: how we can read a file ?? which is in different language????

    Quote Originally Posted by SymbianSangeet View Post
    can any one explain it ..according to me FsSession() is the fuction of CCoeEnv Class but sir why through Static() function we are calling?
    i just know function call through object and pointer object but do'nt know function??
    Do you have a pointer to the object? Usually not. However CCoeEnv::Static provides that, exactly.
    here why I need to convert into 16 bit descriptor .can'nt I use direct in 16 bit ..
    A regular text file contains 8-bit, ASCII data. However on Symbian every text which is going to be displayed has to be in 16-bit, Unicode encoding.
    Can I open test.gif file also in same manner
    The opening and reading part will work. However you can not really display images on a text-screen, like the console.

  8. #8
    Regular Contributor
    Join Date
    Apr 2010
    Posts
    90

    Re: how we can read a file ?? which is in different language????

    HBufC8 *result8 =ReadOpenFileL(_L("z:\\Data\\arun.txt"));
    on this line i getting error

    Creation Time Description Resource Path Location Type
    1278485412156 undefined identifier 'ReadOpenFileL' FlipBookAppUi.cpp FlipBook/src line 127 C/C++ Problem

    and

    console->Printf(_L("File Content :\n %s"),result16);
    on this line getting error..

    Creation Time Description Resource Path Location Type
    1278485412171 illegal use of incomplete struct/union/class 'CConsoleBase' FlipBookAppUi.cpp FlipBook/src line 131 C/C++ Problem

    what is the resion of these type of error and what is the solution whenever now i'm using gui ..

Similar Threads

  1. Replies: 3
    Last Post: 2008-03-04, 11:22
  2. Replies: 6
    Last Post: 2007-03-26, 16:26
  3. DRM PIP File - unable to read file
    By solo95 in forum Symbian Signed Support, Application Packaging and Distribution and Security
    Replies: 1
    Last Post: 2007-03-21, 14:26
  4. Dynamic language change for Help file
    By vishalm in forum Symbian
    Replies: 1
    Last Post: 2006-12-02, 11:56
  5. Help:can Series 40 open the MMS file and read this file??
    By evicn in forum Mobile Java General
    Replies: 0
    Last Post: 2004-04-28, 03:08

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×