Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6590221
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:16:21+00:00 2026-05-25T17:16:21+00:00

I am working in Delphi XE2 I am converting base64 byte array to string

  • 0

I am working in Delphi XE2
I am converting base64 byte array to string using this

TEncoding.UTF7.GetString(byte1)

Then decoding string into byte array using this function

function Base64Decode(const EncodedText: string): TBytes;
var
  DecodedStm: TBytesStream;
  Decoder: TIdDecoderMIME;
begin
  Decoder := TIdDecoderMIME.Create(nil);
  try
    DecodedStm := TBytesStream.Create;
    try
      Decoder.DecodeBegin(DecodedStm);
      Decoder.Decode(EncodedText);
      Decoder.DecodeEnd;
      Result := DecodedStm.Bytes;
    finally
      DecodedStm.Free;
    end;
  finally
    Decoder.Free;
  end;
end;

But input string length is 400 and after decode its byte array length is 8192.

Somewhere it is adding extra spaces… any suggestion as what I’m doing wrong?

Edit…

this is base64 of my data send from c# through tcp to delphi XE2 app
string length = 400

TVpQAAIAAAAEAA8A//8AALgAAAAAAAAAQAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAALoQAA4ftAnNIbgBTM0hkJBUaGlzIHByb2dyYW0gbXVzdCBiZSBydW4gdW5kZXIgV2luMzINCiQ3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBFAABMAQgAGV5CKgAAAAAAAAAA4ACOgQsBAhkArAoAAMQCAAAAAAAwugoA

i receive TBytes in my delphi app when i convert TBytes to string following comes

Tbytes to UTF-7 string
string length = 401

TVpQAAIAAAAEAA8A//8AALgAAAAAAAAAQAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAALoQAA4ftAnNIbgBTM0hkJBUaGlzIHByb2dyYW0gbXVzdCBiZSBydW4gdW5kZXIgV2luMzINCiQ3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA‘AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBFAABMAQgAGV5CKgAAAAAAAAAA4ACOgQsBAhkArAoAAMQCAAAAAAAwugoA

TByte to UTF-8 String
string length= 0 ( ZERO)

TByte to ANSI String
string length= 401

TVpQAAIAAAAEAA8A//8AALgAAAAAAAAAQAAaAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAALoQAA4ftAnNIbgBTM0hkJBUaGlzIHByb2dyYW0gbXVzdCBiZSBydW4gdW5kZXIgV2luMzINCiQ3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA‘AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAFBFAABMAQgAGV5CKgAAAAAAAAAA4ACOgQsBAhkArAoAAMQCAAAAAAAwugoA

there is 1 extra bit is comming in between but i dont know why it is comming.

kindly advice am i doing any thing wrong.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:16:22+00:00Added an answer on May 25, 2026 at 5:16 pm

    You can add one line to get the length you are expecting:

    function Base64Decode(const EncodedText: string): TBytes;
    var
      DecodedStm: TBytesStream;
      Decoder: TIdDecoderMIME;
    begin
      Decoder := TIdDecoderMIME.Create(nil);
      try
        DecodedStm := TBytesStream.Create;
        try
          Decoder.DecodeBegin(DecodedStm);
          Decoder.Decode(EncodedText);
          Decoder.DecodeEnd;
          Result := DecodedStm.Bytes;
          SetLength(Result, DecodedStm.Size);  // add this line
        finally
          DecodedStm.Free;
        end;
      finally
        Decoder.Free;
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, this is a curly one. I'm working on some Delphi code that I
Following up on this question, I'm working on a large Delphi 7 codebase which
I'm working in Delphi 2007. Net, where I can find an example of using
I am working with delphi. After I got a solution of this problem, Now
I am working with delphi. I have an array of points which are continues
I am working with Delphi and DirectX. I want an dynamic array of IDirect3DVertexBuffer9.
This code is not working for me on Delphi XE: http://delphi.about.com/cs/adptips2000/a/bltip0800_5.htm procedure TForm1.FormDeactivate(Sender: TObject)
I am using Delphi 2007 and working on some presentation software. The current module
Working on a console application using Delphi 7, and have run into a problem.
I am currently working on Delphi XE2 trial version. I want to load and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.