Spaces:
Sleeping
Sleeping
| # Remi Serra 202407 | |
| import base64 | |
| import xml.dom.minidom | |
| def decode_b64_string_to_pretty_xml(encoded_string): | |
| # split | |
| split = encoded_string.split(",") | |
| if len(split) > 1: | |
| encoded = split[1] | |
| else: | |
| encoded = encoded_string | |
| # decode | |
| decoded_xml = base64.b64decode(encoded).decode("utf-8") | |
| # pretify XML | |
| dom = xml.dom.minidom.parseString(decoded_xml) | |
| pretty_xml_as_string = dom.toprettyxml(indent="", newl="") | |
| return pretty_xml_as_string | |
| def encode_svg_xml_to_b64_string(svg_xml): | |
| xml_b64 = base64.b64encode(svg_xml.encode("utf-8")).decode("utf-8") | |
| # print(f"encode_svg_xml_to_b64_string:xml_b64:{xml_b64}") | |
| return xml_b64 | |