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.
  • RipleyR Offline
    RipleyR Offline
    Ripley
    wrote on last edited by Ripley
    #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.

    JonBJ 1 Reply Last reply
    0
    • RipleyR Ripley

      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.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #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)?

      RipleyR 1 Reply Last reply
      0
      • JonBJ JonB

        @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)?

        RipleyR Offline
        RipleyR Offline
        Ripley
        wrote on 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.

        JonBJ 1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 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
          • RipleyR Ripley

            @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.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #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

            • Login

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