Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to get a base64 of a base64 encoding inside a string?
Forum Updated to NodeBB v4.3 + New Features

How to get a base64 of a base64 encoding inside a string?

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Ripley
    wrote on 7 Apr 2020, 20:00 last edited by Ripley 4 Jul 2020, 20:42
    #1

    I have a base 64 inside a string, but my object is a Qstring I need to take it to a QByteArray but without losing the value of base 64

    example:

    QString var =("b'L4m2aeeFG8vNnsFUEsBAhQDFAAAAAgAAAAhAPoTdNRkAQAANwcAABMAAAAAAAAAAAAAAAAAAAAAAFtDb250ZW50X1R5cGVzXS54bWxQSwECFAMUAAAACAAAACEA8p9J2ukAAABLAgAACwAAA' ")

    QByteArray filecontent_pfo = QByteArray::fromBase64(var.toUtf8());

    but at the moment this doesn't give me the wishes.

    J 1 Reply Last reply 7 Apr 2020, 20:49
    0
    • R Ripley
      7 Apr 2020, 20:00

      I have a base 64 inside a string, but my object is a Qstring I need to take it to a QByteArray but without losing the value of base 64

      example:

      QString var =("b'L4m2aeeFG8vNnsFUEsBAhQDFAAAAAgAAAAhAPoTdNRkAQAANwcAABMAAAAAAAAAAAAAAAAAAAAAAFtDb250ZW50X1R5cGVzXS54bWxQSwECFAMUAAAACAAAACEA8p9J2ukAAABLAgAACwAAA' ")

      QByteArray filecontent_pfo = QByteArray::fromBase64(var.toUtf8());

      but at the moment this doesn't give me the wishes.

      J Offline
      J Offline
      JonB
      wrote on 7 Apr 2020, 20:49 last edited by JonB 4 Jul 2020, 20:53
      #2

      @Ripley said in How to get a base64 of a base64 encoding inside a string?:

      QString var =("b'L4m2aeeFG8vNnsFUEsBAhQDFAAAAAgAAAAhAPoTdNRkAQAANwcAABMAAAAAAAAAAAAAAAAAAAAAAFtDb250ZW50X1R5cGVzXS54bWxQSwECFAMUAAAACAAAACEA8p9J2ukAAABLAgAACwAAA' ")
      

      Do you mean you just need to take off the leading b' and trailing ' (plus spaces) and then treat that (via QByteArray::QByteArray(const char *data, int size = -1) if necessary, don't know if you need that, the QString after the removal should do?) as the QByteArray value to pass to QByteArray QByteArray::fromBase64(const QByteArray &base64)?

      R 1 Reply Last reply 7 Apr 2020, 21:14
      0
      • J JonB
        7 Apr 2020, 20:49

        @Ripley said in How to get a base64 of a base64 encoding inside a string?:

        QString var =("b'L4m2aeeFG8vNnsFUEsBAhQDFAAAAAgAAAAhAPoTdNRkAQAANwcAABMAAAAAAAAAAAAAAAAAAAAAAFtDb250ZW50X1R5cGVzXS54bWxQSwECFAMUAAAACAAAACEA8p9J2ukAAABLAgAACwAAA' ")
        

        Do you mean you just need to take off the leading b' and trailing ' (plus spaces) and then treat that (via QByteArray::QByteArray(const char *data, int size = -1) if necessary, don't know if you need that, the QString after the removal should do?) as the QByteArray value to pass to QByteArray QByteArray::fromBase64(const QByteArray &base64)?

        R Offline
        R Offline
        Ripley
        wrote on 7 Apr 2020, 21:14 last edited by
        #3

        @JonB Yes, i get the variable as a binary decode this as base64 from the server which sent me this example that is var. My real problem is that this example is a xlsx sheet and knowing not how to decode this. Just var is a little example.

        J 1 Reply Last reply 8 Apr 2020, 07:16
        0
        • C Offline
          C Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 8 Apr 2020, 07:04 last edited by
          #4

          See QByteArray::fromBase64()

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          0
          • R Ripley
            7 Apr 2020, 21:14

            @JonB Yes, i get the variable as a binary decode this as base64 from the server which sent me this example that is var. My real problem is that this example is a xlsx sheet and knowing not how to decode this. Just var is a little example.

            J Offline
            J Offline
            JonB
            wrote on 8 Apr 2020, 07:16 last edited by JonB 4 Aug 2020, 07:20
            #5

            @Ripley
            I suggested what you need to do in my first reply. You have a string which looks like "b'...' ". You need to strip off the leading & trailing markers before passing to QByteArray::fromBase64().

            1 Reply Last reply
            0

            1/5

            7 Apr 2020, 20:00

            • Login

            • Login or register to search.
            1 out of 5
            • First post
              1/5
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved