ANSI-only strings in memory? avoiding Unicode conversion to save memory?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 15 of 15

Thread: ANSI-only strings in memory? avoiding Unicode conversion to save memory?

  1. #1
    - John of Arc - Guest

    ANSI-only strings in memory? avoiding Unicode conversion to save memory?

    How does one save on memory by avoiding string conversion to UniCode?
    Is there a way to do that?

    For example, if one is reading from a large text file, operating on the
    contents, then writing to a second textfile (using the API file i/o
    functions), is there a way to keep everything ANSI so as to half the memory
    involved?

    Would one use arrays of bytes instead of strings? Is that possible in VB?
    StrConv()?
    StrPtr()?

    Thanks for any suggestions or any URLs that treat on the topic.




  2. #2
    Bill McCarthy Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?

    Hi John,

    You could use a byte array. Open the file as binary and dump the contents
    into a byte array. Unfortunately VB only has a unicode or OLE string
    representation internally. So if you are working with strings, you will
    always have to convert from unicode to ansi etc. You can use CopyMemory api
    passing the string byval to get an ansi copy, so tasks such as replacing
    one part of the file with another string of the same length are relatively
    simple with minimal overhead (unless the string being replaced is large
    too). Another alternative, is to use memory mapped files for large files.,
    or just read the file in chunks rather than all at once.

    I would say that the real limiting factor in which approach you take is
    dependant on what operations you want to do with the contents. Can you
    provide some more details on that, and approx. file sizes ?



    "- John of Arc -" <666@666.666> wrote in message
    news:3907a87a@news.devx.com...
    > How does one save on memory by avoiding string conversion to UniCode?
    > Is there a way to do that?
    >
    > For example, if one is reading from a large text file, operating on the
    > contents, then writing to a second textfile (using the API file i/o
    > functions), is there a way to keep everything ANSI so as to half the

    memory
    > involved?
    >
    > Would one use arrays of bytes instead of strings? Is that possible in VB?
    > StrConv()?
    > StrPtr()?
    >
    > Thanks for any suggestions or any URLs that treat on the topic.
    >
    >
    >




  3. #3
    Bill McCarthy Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?

    Hi John,

    You could use a byte array. Open the file as binary and dump the contents
    into a byte array. Unfortunately VB only has a unicode or OLE string
    representation internally. So if you are working with strings, you will
    always have to convert from unicode to ansi etc. You can use CopyMemory api
    passing the string byval to get an ansi copy, so tasks such as replacing
    one part of the file with another string of the same length are relatively
    simple with minimal overhead (unless the string being replaced is large
    too). Another alternative, is to use memory mapped files for large files.,
    or just read the file in chunks rather than all at once.

    I would say that the real limiting factor in which approach you take is
    dependant on what operations you want to do with the contents. Can you
    provide some more details on that, and approx. file sizes ?



    "- John of Arc -" <666@666.666> wrote in message
    news:3907a87a@news.devx.com...
    > How does one save on memory by avoiding string conversion to UniCode?
    > Is there a way to do that?
    >
    > For example, if one is reading from a large text file, operating on the
    > contents, then writing to a second textfile (using the API file i/o
    > functions), is there a way to keep everything ANSI so as to half the

    memory
    > involved?
    >
    > Would one use arrays of bytes instead of strings? Is that possible in VB?
    > StrConv()?
    > StrPtr()?
    >
    > Thanks for any suggestions or any URLs that treat on the topic.
    >
    >
    >




  4. #4
    Michael \(michka\) Kaplan Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?

    This is NOT a solution.

    COM uses Unicode.... ONLY. VB creates COM components. The notion that you
    will save in terms of memory ignores the fact that you will have to convert
    back to Unicode for every single operation you would perform with a string.

    StrPtr has nothing to do with ANSI strings.... it is in fact the way to keep
    string as Unicode when passed to dlls, etc.

    --
    MichKa
    "Cause it's a bittersweet symphony, thats life..." -- The Verve

    random junk of dubious value, at the multilingual,
    no scripts required, http://www.trigeminal.com/

    "- John of Arc -" <666@666.666> wrote in message
    news:3907a87a@news.devx.com...
    > How does one save on memory by avoiding string conversion to UniCode?
    > Is there a way to do that?
    >
    > For example, if one is reading from a large text file, operating on the
    > contents, then writing to a second textfile (using the API file i/o
    > functions), is there a way to keep everything ANSI so as to half the

    memory
    > involved?
    >
    > Would one use arrays of bytes instead of strings? Is that possible in VB?
    > StrConv()?
    > StrPtr()?
    >
    > Thanks for any suggestions or any URLs that treat on the topic.
    >
    >
    >




  5. #5
    Michael \(michka\) Kaplan Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?

    This is NOT a solution.

    COM uses Unicode.... ONLY. VB creates COM components. The notion that you
    will save in terms of memory ignores the fact that you will have to convert
    back to Unicode for every single operation you would perform with a string.

    StrPtr has nothing to do with ANSI strings.... it is in fact the way to keep
    string as Unicode when passed to dlls, etc.

    --
    MichKa
    "Cause it's a bittersweet symphony, thats life..." -- The Verve

    random junk of dubious value, at the multilingual,
    no scripts required, http://www.trigeminal.com/

    "- John of Arc -" <666@666.666> wrote in message
    news:3907a87a@news.devx.com...
    > How does one save on memory by avoiding string conversion to UniCode?
    > Is there a way to do that?
    >
    > For example, if one is reading from a large text file, operating on the
    > contents, then writing to a second textfile (using the API file i/o
    > functions), is there a way to keep everything ANSI so as to half the

    memory
    > involved?
    >
    > Would one use arrays of bytes instead of strings? Is that possible in VB?
    > StrConv()?
    > StrPtr()?
    >
    > Thanks for any suggestions or any URLs that treat on the topic.
    >
    >
    >




  6. #6
    Michael \(michka\) Kaplan Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?

    Also, note that resources under Win32 are ALWAYS Unicode also..... even on
    Win9x. And there is no way to store strings in your code as ANSI. Therefore,
    you have no way to save the space, and the memory/perf hit of adding even
    MORE conversions would outweigh any benefits you might think you could
    receive by using ANSI strings.

    --
    MichKa
    "Cause it's a bittersweet symphony, thats life..." -- The Verve

    random junk of dubious value, at the multilingual,
    no scripts required, http://www.trigeminal.com/

    "- John of Arc -" <666@666.666> wrote in message
    news:3907a87a@news.devx.com...
    > How does one save on memory by avoiding string conversion to UniCode?
    > Is there a way to do that?
    >
    > For example, if one is reading from a large text file, operating on the
    > contents, then writing to a second textfile (using the API file i/o
    > functions), is there a way to keep everything ANSI so as to half the

    memory
    > involved?
    >
    > Would one use arrays of bytes instead of strings? Is that possible in VB?
    > StrConv()?
    > StrPtr()?
    >
    > Thanks for any suggestions or any URLs that treat on the topic.
    >
    >
    >




  7. #7
    Michael \(michka\) Kaplan Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?

    Also, note that resources under Win32 are ALWAYS Unicode also..... even on
    Win9x. And there is no way to store strings in your code as ANSI. Therefore,
    you have no way to save the space, and the memory/perf hit of adding even
    MORE conversions would outweigh any benefits you might think you could
    receive by using ANSI strings.

    --
    MichKa
    "Cause it's a bittersweet symphony, thats life..." -- The Verve

    random junk of dubious value, at the multilingual,
    no scripts required, http://www.trigeminal.com/

    "- John of Arc -" <666@666.666> wrote in message
    news:3907a87a@news.devx.com...
    > How does one save on memory by avoiding string conversion to UniCode?
    > Is there a way to do that?
    >
    > For example, if one is reading from a large text file, operating on the
    > contents, then writing to a second textfile (using the API file i/o
    > functions), is there a way to keep everything ANSI so as to half the

    memory
    > involved?
    >
    > Would one use arrays of bytes instead of strings? Is that possible in VB?
    > StrConv()?
    > StrPtr()?
    >
    > Thanks for any suggestions or any URLs that treat on the topic.
    >
    >
    >




  8. #8
    Mike Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?


    Michael

    But couldn't you open the file as binary and read it into a byte array. Then
    perform any modifications and write it back? Sure this would be a huge hassle,
    but possible. A text file seams to be stored as ANSI (by checking its size),
    so there would never be an ANSI-UNICODE conversion.

    Mike


    "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com> wrote:
    >Also, note that resources under Win32 are ALWAYS Unicode also..... even

    on
    >Win9x. And there is no way to store strings in your code as ANSI. Therefore,
    >you have no way to save the space, and the memory/perf hit of adding even
    >MORE conversions would outweigh any benefits you might think you could
    >receive by using ANSI strings.
    >
    >--
    >MichKa
    >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    >
    >random junk of dubious value, at the multilingual,
    >no scripts required, http://www.trigeminal.com/
    >
    >"- John of Arc -" <666@666.666> wrote in message
    >news:3907a87a@news.devx.com...
    >> How does one save on memory by avoiding string conversion to UniCode?
    >> Is there a way to do that?
    >>
    >> For example, if one is reading from a large text file, operating on the
    >> contents, then writing to a second textfile (using the API file i/o
    >> functions), is there a way to keep everything ANSI so as to half the

    >memory
    >> involved?
    >>
    >> Would one use arrays of bytes instead of strings? Is that possible in

    VB?
    >> StrConv()?
    >> StrPtr()?
    >>
    >> Thanks for any suggestions or any URLs that treat on the topic.
    >>
    >>
    >>

    >
    >



  9. #9
    Mike Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?


    Michael

    But couldn't you open the file as binary and read it into a byte array. Then
    perform any modifications and write it back? Sure this would be a huge hassle,
    but possible. A text file seams to be stored as ANSI (by checking its size),
    so there would never be an ANSI-UNICODE conversion.

    Mike


    "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com> wrote:
    >Also, note that resources under Win32 are ALWAYS Unicode also..... even

    on
    >Win9x. And there is no way to store strings in your code as ANSI. Therefore,
    >you have no way to save the space, and the memory/perf hit of adding even
    >MORE conversions would outweigh any benefits you might think you could
    >receive by using ANSI strings.
    >
    >--
    >MichKa
    >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    >
    >random junk of dubious value, at the multilingual,
    >no scripts required, http://www.trigeminal.com/
    >
    >"- John of Arc -" <666@666.666> wrote in message
    >news:3907a87a@news.devx.com...
    >> How does one save on memory by avoiding string conversion to UniCode?
    >> Is there a way to do that?
    >>
    >> For example, if one is reading from a large text file, operating on the
    >> contents, then writing to a second textfile (using the API file i/o
    >> functions), is there a way to keep everything ANSI so as to half the

    >memory
    >> involved?
    >>
    >> Would one use arrays of bytes instead of strings? Is that possible in

    VB?
    >> StrConv()?
    >> StrPtr()?
    >>
    >> Thanks for any suggestions or any URLs that treat on the topic.
    >>
    >>
    >>

    >
    >



  10. #10
    Michael \(michka\) Kaplan Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?

    Sigh... but none of the VB functions for dealing with strings expect ANSI
    strings.... so you are working hard to circumvent the very things that VB
    would do for you.

    In other words, is it possible? YES. Is it stupid? YES.

    --
    MichKa
    "Cause it's a bittersweet symphony, thats life..." -- The Verve

    random junk of dubious value, at the multilingual,
    no scripts required, http://www.trigeminal.com/

    "Mike" <m_culley@one.net.au> wrote in message
    news:39083f84$1@news.devx.com...
    >
    > Michael
    >
    > But couldn't you open the file as binary and read it into a byte array.

    Then
    > perform any modifications and write it back? Sure this would be a huge

    hassle,
    > but possible. A text file seams to be stored as ANSI (by checking its

    size),
    > so there would never be an ANSI-UNICODE conversion.
    >
    > Mike
    >
    >
    > "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com>

    wrote:
    > >Also, note that resources under Win32 are ALWAYS Unicode also..... even

    > on
    > >Win9x. And there is no way to store strings in your code as ANSI.

    Therefore,
    > >you have no way to save the space, and the memory/perf hit of adding even
    > >MORE conversions would outweigh any benefits you might think you could
    > >receive by using ANSI strings.
    > >
    > >--
    > >MichKa
    > >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    > >
    > >random junk of dubious value, at the multilingual,
    > >no scripts required, http://www.trigeminal.com/
    > >
    > >"- John of Arc -" <666@666.666> wrote in message
    > >news:3907a87a@news.devx.com...
    > >> How does one save on memory by avoiding string conversion to UniCode?
    > >> Is there a way to do that?
    > >>
    > >> For example, if one is reading from a large text file, operating on the
    > >> contents, then writing to a second textfile (using the API file i/o
    > >> functions), is there a way to keep everything ANSI so as to half the

    > >memory
    > >> involved?
    > >>
    > >> Would one use arrays of bytes instead of strings? Is that possible in

    > VB?
    > >> StrConv()?
    > >> StrPtr()?
    > >>
    > >> Thanks for any suggestions or any URLs that treat on the topic.
    > >>
    > >>
    > >>

    > >
    > >

    >




  11. #11
    Michael \(michka\) Kaplan Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?

    Sigh... but none of the VB functions for dealing with strings expect ANSI
    strings.... so you are working hard to circumvent the very things that VB
    would do for you.

    In other words, is it possible? YES. Is it stupid? YES.

    --
    MichKa
    "Cause it's a bittersweet symphony, thats life..." -- The Verve

    random junk of dubious value, at the multilingual,
    no scripts required, http://www.trigeminal.com/

    "Mike" <m_culley@one.net.au> wrote in message
    news:39083f84$1@news.devx.com...
    >
    > Michael
    >
    > But couldn't you open the file as binary and read it into a byte array.

    Then
    > perform any modifications and write it back? Sure this would be a huge

    hassle,
    > but possible. A text file seams to be stored as ANSI (by checking its

    size),
    > so there would never be an ANSI-UNICODE conversion.
    >
    > Mike
    >
    >
    > "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com>

    wrote:
    > >Also, note that resources under Win32 are ALWAYS Unicode also..... even

    > on
    > >Win9x. And there is no way to store strings in your code as ANSI.

    Therefore,
    > >you have no way to save the space, and the memory/perf hit of adding even
    > >MORE conversions would outweigh any benefits you might think you could
    > >receive by using ANSI strings.
    > >
    > >--
    > >MichKa
    > >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    > >
    > >random junk of dubious value, at the multilingual,
    > >no scripts required, http://www.trigeminal.com/
    > >
    > >"- John of Arc -" <666@666.666> wrote in message
    > >news:3907a87a@news.devx.com...
    > >> How does one save on memory by avoiding string conversion to UniCode?
    > >> Is there a way to do that?
    > >>
    > >> For example, if one is reading from a large text file, operating on the
    > >> contents, then writing to a second textfile (using the API file i/o
    > >> functions), is there a way to keep everything ANSI so as to half the

    > >memory
    > >> involved?
    > >>
    > >> Would one use arrays of bytes instead of strings? Is that possible in

    > VB?
    > >> StrConv()?
    > >> StrPtr()?
    > >>
    > >> Thanks for any suggestions or any URLs that treat on the topic.
    > >>
    > >>
    > >>

    > >
    > >

    >




  12. #12
    Mike Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?


    I was just saying that it was possible.

    I also think that in some _rare_ cases it would be useful and not stupid
    at all.

    Mike


    "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com> wrote:
    >Sigh... but none of the VB functions for dealing with strings expect ANSI
    >strings.... so you are working hard to circumvent the very things that VB
    >would do for you.
    >
    >In other words, is it possible? YES. Is it stupid? YES.
    >
    >--
    >MichKa
    >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    >
    >random junk of dubious value, at the multilingual,
    >no scripts required, http://www.trigeminal.com/
    >
    >"Mike" <m_culley@one.net.au> wrote in message
    >news:39083f84$1@news.devx.com...
    >>
    >> Michael
    >>
    >> But couldn't you open the file as binary and read it into a byte array.

    >Then
    >> perform any modifications and write it back? Sure this would be a huge

    >hassle,
    >> but possible. A text file seams to be stored as ANSI (by checking its

    >size),
    >> so there would never be an ANSI-UNICODE conversion.
    >>
    >> Mike
    >>
    >>
    >> "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com>

    >wrote:
    >> >Also, note that resources under Win32 are ALWAYS Unicode also..... even

    >> on
    >> >Win9x. And there is no way to store strings in your code as ANSI.

    >Therefore,
    >> >you have no way to save the space, and the memory/perf hit of adding

    even
    >> >MORE conversions would outweigh any benefits you might think you could
    >> >receive by using ANSI strings.
    >> >
    >> >--
    >> >MichKa
    >> >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    >> >
    >> >random junk of dubious value, at the multilingual,
    >> >no scripts required, http://www.trigeminal.com/
    >> >
    >> >"- John of Arc -" <666@666.666> wrote in message
    >> >news:3907a87a@news.devx.com...
    >> >> How does one save on memory by avoiding string conversion to UniCode?
    >> >> Is there a way to do that?
    >> >>
    >> >> For example, if one is reading from a large text file, operating on

    the
    >> >> contents, then writing to a second textfile (using the API file i/o
    >> >> functions), is there a way to keep everything ANSI so as to half the
    >> >memory
    >> >> involved?
    >> >>
    >> >> Would one use arrays of bytes instead of strings? Is that possible

    in
    >> VB?
    >> >> StrConv()?
    >> >> StrPtr()?
    >> >>
    >> >> Thanks for any suggestions or any URLs that treat on the topic.
    >> >>
    >> >>
    >> >>
    >> >
    >> >

    >>

    >
    >



  13. #13
    Mike Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?


    I was just saying that it was possible.

    I also think that in some _rare_ cases it would be useful and not stupid
    at all.

    Mike


    "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com> wrote:
    >Sigh... but none of the VB functions for dealing with strings expect ANSI
    >strings.... so you are working hard to circumvent the very things that VB
    >would do for you.
    >
    >In other words, is it possible? YES. Is it stupid? YES.
    >
    >--
    >MichKa
    >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    >
    >random junk of dubious value, at the multilingual,
    >no scripts required, http://www.trigeminal.com/
    >
    >"Mike" <m_culley@one.net.au> wrote in message
    >news:39083f84$1@news.devx.com...
    >>
    >> Michael
    >>
    >> But couldn't you open the file as binary and read it into a byte array.

    >Then
    >> perform any modifications and write it back? Sure this would be a huge

    >hassle,
    >> but possible. A text file seams to be stored as ANSI (by checking its

    >size),
    >> so there would never be an ANSI-UNICODE conversion.
    >>
    >> Mike
    >>
    >>
    >> "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com>

    >wrote:
    >> >Also, note that resources under Win32 are ALWAYS Unicode also..... even

    >> on
    >> >Win9x. And there is no way to store strings in your code as ANSI.

    >Therefore,
    >> >you have no way to save the space, and the memory/perf hit of adding

    even
    >> >MORE conversions would outweigh any benefits you might think you could
    >> >receive by using ANSI strings.
    >> >
    >> >--
    >> >MichKa
    >> >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    >> >
    >> >random junk of dubious value, at the multilingual,
    >> >no scripts required, http://www.trigeminal.com/
    >> >
    >> >"- John of Arc -" <666@666.666> wrote in message
    >> >news:3907a87a@news.devx.com...
    >> >> How does one save on memory by avoiding string conversion to UniCode?
    >> >> Is there a way to do that?
    >> >>
    >> >> For example, if one is reading from a large text file, operating on

    the
    >> >> contents, then writing to a second textfile (using the API file i/o
    >> >> functions), is there a way to keep everything ANSI so as to half the
    >> >memory
    >> >> involved?
    >> >>
    >> >> Would one use arrays of bytes instead of strings? Is that possible

    in
    >> VB?
    >> >> StrConv()?
    >> >> StrPtr()?
    >> >>
    >> >> Thanks for any suggestions or any URLs that treat on the topic.
    >> >>
    >> >>
    >> >>
    >> >
    >> >

    >>

    >
    >



  14. #14
    Michael \(michka\) Kaplan Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?

    Yes, in a provincial, US-ENGLISH only situation, where you never need the
    second byte, i suppose you could make such an argument. Given my bent these
    dys to suggesting that people do the minimal effort to globalize their apps,
    using Unicode where it can be done, since it is the basis for strings in COM
    and VB, and elsewhere, is what makes the most sense. :-)

    --
    MichKa
    "Cause it's a bittersweet symphony, thats life..." -- The Verve

    random junk of dubious value, at the multilingual,
    no scripts required, http://www.trigeminal.com/

    "Mike" <m_culley@one.net.au> wrote in message
    news:39097646$1@news.devx.com...
    >
    > I was just saying that it was possible.
    >
    > I also think that in some _rare_ cases it would be useful and not stupid
    > at all.
    >
    > Mike
    >
    >
    > "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com>

    wrote:
    > >Sigh... but none of the VB functions for dealing with strings expect ANSI
    > >strings.... so you are working hard to circumvent the very things that VB
    > >would do for you.
    > >
    > >In other words, is it possible? YES. Is it stupid? YES.
    > >
    > >--
    > >MichKa
    > >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    > >
    > >random junk of dubious value, at the multilingual,
    > >no scripts required, http://www.trigeminal.com/
    > >
    > >"Mike" <m_culley@one.net.au> wrote in message
    > >news:39083f84$1@news.devx.com...
    > >>
    > >> Michael
    > >>
    > >> But couldn't you open the file as binary and read it into a byte array.

    > >Then
    > >> perform any modifications and write it back? Sure this would be a huge

    > >hassle,
    > >> but possible. A text file seams to be stored as ANSI (by checking its

    > >size),
    > >> so there would never be an ANSI-UNICODE conversion.
    > >>
    > >> Mike
    > >>
    > >>
    > >> "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com>

    > >wrote:
    > >> >Also, note that resources under Win32 are ALWAYS Unicode also.....

    even
    > >> on
    > >> >Win9x. And there is no way to store strings in your code as ANSI.

    > >Therefore,
    > >> >you have no way to save the space, and the memory/perf hit of adding

    > even
    > >> >MORE conversions would outweigh any benefits you might think you could
    > >> >receive by using ANSI strings.
    > >> >
    > >> >--
    > >> >MichKa
    > >> >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    > >> >
    > >> >random junk of dubious value, at the multilingual,
    > >> >no scripts required, http://www.trigeminal.com/
    > >> >
    > >> >"- John of Arc -" <666@666.666> wrote in message
    > >> >news:3907a87a@news.devx.com...
    > >> >> How does one save on memory by avoiding string conversion to

    UniCode?
    > >> >> Is there a way to do that?
    > >> >>
    > >> >> For example, if one is reading from a large text file, operating on

    > the
    > >> >> contents, then writing to a second textfile (using the API file i/o
    > >> >> functions), is there a way to keep everything ANSI so as to half the
    > >> >memory
    > >> >> involved?
    > >> >>
    > >> >> Would one use arrays of bytes instead of strings? Is that possible

    > in
    > >> VB?
    > >> >> StrConv()?
    > >> >> StrPtr()?
    > >> >>
    > >> >> Thanks for any suggestions or any URLs that treat on the topic.
    > >> >>
    > >> >>
    > >> >>
    > >> >
    > >> >
    > >>

    > >
    > >

    >




  15. #15
    Michael \(michka\) Kaplan Guest

    Re: ANSI-only strings in memory? avoiding Unicode conversion to save memory?

    Yes, in a provincial, US-ENGLISH only situation, where you never need the
    second byte, i suppose you could make such an argument. Given my bent these
    dys to suggesting that people do the minimal effort to globalize their apps,
    using Unicode where it can be done, since it is the basis for strings in COM
    and VB, and elsewhere, is what makes the most sense. :-)

    --
    MichKa
    "Cause it's a bittersweet symphony, thats life..." -- The Verve

    random junk of dubious value, at the multilingual,
    no scripts required, http://www.trigeminal.com/

    "Mike" <m_culley@one.net.au> wrote in message
    news:39097646$1@news.devx.com...
    >
    > I was just saying that it was possible.
    >
    > I also think that in some _rare_ cases it would be useful and not stupid
    > at all.
    >
    > Mike
    >
    >
    > "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com>

    wrote:
    > >Sigh... but none of the VB functions for dealing with strings expect ANSI
    > >strings.... so you are working hard to circumvent the very things that VB
    > >would do for you.
    > >
    > >In other words, is it possible? YES. Is it stupid? YES.
    > >
    > >--
    > >MichKa
    > >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    > >
    > >random junk of dubious value, at the multilingual,
    > >no scripts required, http://www.trigeminal.com/
    > >
    > >"Mike" <m_culley@one.net.au> wrote in message
    > >news:39083f84$1@news.devx.com...
    > >>
    > >> Michael
    > >>
    > >> But couldn't you open the file as binary and read it into a byte array.

    > >Then
    > >> perform any modifications and write it back? Sure this would be a huge

    > >hassle,
    > >> but possible. A text file seams to be stored as ANSI (by checking its

    > >size),
    > >> so there would never be an ANSI-UNICODE conversion.
    > >>
    > >> Mike
    > >>
    > >>
    > >> "Michael \(michka\) Kaplan" <former_mvp@spamfree.trigeminal.nospam.com>

    > >wrote:
    > >> >Also, note that resources under Win32 are ALWAYS Unicode also.....

    even
    > >> on
    > >> >Win9x. And there is no way to store strings in your code as ANSI.

    > >Therefore,
    > >> >you have no way to save the space, and the memory/perf hit of adding

    > even
    > >> >MORE conversions would outweigh any benefits you might think you could
    > >> >receive by using ANSI strings.
    > >> >
    > >> >--
    > >> >MichKa
    > >> >"Cause it's a bittersweet symphony, thats life..." -- The Verve
    > >> >
    > >> >random junk of dubious value, at the multilingual,
    > >> >no scripts required, http://www.trigeminal.com/
    > >> >
    > >> >"- John of Arc -" <666@666.666> wrote in message
    > >> >news:3907a87a@news.devx.com...
    > >> >> How does one save on memory by avoiding string conversion to

    UniCode?
    > >> >> Is there a way to do that?
    > >> >>
    > >> >> For example, if one is reading from a large text file, operating on

    > the
    > >> >> contents, then writing to a second textfile (using the API file i/o
    > >> >> functions), is there a way to keep everything ANSI so as to half the
    > >> >memory
    > >> >> involved?
    > >> >>
    > >> >> Would one use arrays of bytes instead of strings? Is that possible

    > in
    > >> VB?
    > >> >> StrConv()?
    > >> >> StrPtr()?
    > >> >>
    > >> >> Thanks for any suggestions or any URLs that treat on the topic.
    > >> >>
    > >> >>
    > >> >>
    > >> >
    > >> >
    > >>

    > >
    > >

    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center