在Swift中将数据转换为字符串

时间:2017-06-08 00:30:17

标签: swift string

我试图将一段Data转换为String,但遇到了问题。我的数据存储在变量d中,具有以下调试信息。

Printing description of token:
▿ Optional<Data>
  ▿ some : 2281 bytes
    - count : 2281
    ▿ pointer : 0x0000000150810410
      - pointerValue : 5645599760

我正在尝试将其保存为var string:String?

定义的字符串
self.string = String.init(data: d!, encoding: .utf16)

我尝试使用.utf8.utf16.utf32.ascii作为编码类型,无论我尝试self.string等于{{1 }}。有什么想法吗?

编辑1:使用nil时,我得到一些可爱的疯狂输出。所以,我已经接近了,还不够近。

.unicode

编辑2:响应NobodyNada, Ȁ\0急୏勳锢湝ѐ�逸볶뾖択ੲ㣩⁝痲購�㖦夫븅誜ྎ�⫋柯띴霜ꑟ綅橩侱맄ஔאַ穚钘뀄燝㒍怌ᝎໟໜ隩쭡껶⺙�ﲽ셦⊫◦�켮٪ᓦ܋贒酏쫇㑖�ꓷꩾ伈\0נ耙襘᪬Ⅲ탼᱀雬�逥栦ᡷㆸ翅⼦鲣䆗꿨翾㰁㭝쬝錟ℕ쮕랐붲훒㲫갆ꆳ룻⋭ꈉ㻕x儀쨠桪ﱀ픍漚㹨䘗쪃枏ݢ蜫北��ᒲ쥹푥詜ል꟝퉯�笑盞鼊㹉긴㒰뫾뼋繐☟㉽莭ꝇ晴ឃ촴Ⲷ鴚餁泸곶ᜇ劋ഖ卫⻍泊櫶踶㫮쿶ߠ迲긆擺迹虡ཟ融㦆唿泤垎혣䶢桙䜨壖깚᤽꽻䪭₭ᱚ㱚䙳ഘ體䊘멷�肯鋫ꕶ䉿㘳ꐨꅴ㸒꼋龛㕒럄ﳵ풭ᑀ垢ꘞ㺼㠖꺮ꙧ깳撤呄醰뜧䅉纴⺥㸿蚄츣긣ᮕ耻䓽⁙婁䝒熨ﵕ�㖆�嫨뉋鶝ᱨ닊궟ꦈﶱ혁୦켱概ꔩⴆ�䗞ዻ鲔峢ꈕ仞몋襲䮧ꀹ灕뒓ᎋサ癪ꥱ咑ꝏ㥀洹ݑ쀉荏猓緊ꏘ顙ધ瘦㲘퀻ે㉁ṀₖꉟᏜ쯓㆔滘䲱䈔倁♠닡䥞챵긎뎄褈ﳛ쎈宊沉ិ盌ﮈ桠¼죪뵂䞄쯉薛妤ի帮럊厀쾏瞃尡貙⻥띈ર㽩瘠캹낅쯯촧㔮�泌ூ鯿䂼�왓㨅彛迁泮ĩ炭떧㈧鐾ᦋꮂ荗꣓窍㮱竐芶ᅨ굑㞣썵ﴕ쳱烏큏䯎ꚽ⑷嚱⊒퐅ᆎ韺蟑⊓굠阶쯣愮㋆浡䛢簸疢ꞛ룇๙眚飀䱭♇ካ㮏좾銉韒巜꬟쇼⳪y믗瀮∦ﳁ솖⁛檹뤪랁䂿푅⨂৭䳐嘠渆࿫ࡱ敮⏃㮭䳄彤脸ᷧ扛ꀺꖽ䅉峵㻉篪�핞뤝桴ᛳ莏흹訖ف뵌ኖ쳹㈕舞篠ꑢფ栘ᳬ茹貘郁ᒡ끦ᴙ⁒茰쓉괷莶ꙏ庹꾢ᣂ䶛朾莊畀缾蜿萗쏵꾺檜嬹躊拾疻군붹க㢝傅릣鰭癝ﱯⳆꁜ�䍴�抄㢻돣寞丠纡췺国ᚂ憐쾜䷕ 뙳䏶Ꭴ㮜㍋蹷ಚ蓥ᯐオЀ븚猊訓溣웺䇚ﮓ憹軡풬铏຦퓙亶빑⁓珈縛瘐檢譔檹簩㱍⹺哋讪⚝䖬꫇䑐㭪\"駱臹୏몮ڷ뼿㥽趘鹋ⅿ䰝ᨘ枙ˇ粮䃷ᵱ᳓৭潥Ⲡ릮꠪兞�᩺潝ꐧ萇쉣蔫䀎૜ᬋ嵴ꧽ㧝뫲躱딺岻텘ᦉ窰硾꓍睠줕㶧搮뛇Ẇ㖘욎铣䀙䇿糴Ⱓ㞱ഴ쭷ᔌጼ⏯䜘췠Ȉ株⍜멾쓄ⶣ붆쯯➣롞궡枪딭碡㙦集ತ⡓罠啫չ礂ᐈ崔ོ肝⋄⹵煨큾Έ迡ጿ柜폻Ṻ枚謧뙥辅ꔊ㩩ꯡ�钇㟥禜柜調厅岦Ⲩ철ᡶ颜쎝亨⬒닜䄐쐨Ꞌ劬䉄མᑤꚖ篏៽㮬㾚펣쀙簌➄髙삣╄⺺錒ᵡ쯧콨⺫夦齲쨗⋿㛄ݧᆁ탿骅ⵚ樱拐ⶡ딚覈紭ꇗ挐攆㶮籭㡌ሃ鵆叉刞ꦾ�倰ጳᴈ譮翦ꈬ羏ḗ䗺乽ሊ嫩Ⴑ欮根嗚ྍ⟦剜꜖秶우対蟳餶ㆽ苯쐞๞§뱅㪺壭㼊꛵㷷ᶾ坾෦鲐踓ゞ鎰捯漋࣍隳ꔜ醛胞轖⤭껉뉸Ȱ핂췴멋䵆﹂荂与᷼槣Ọ斌䁔ట萖ℿ䦦�ワ䉠ꎠౘ�⸗喂褶멊군ェ謷⒴�蟺胨嫗皷啤즎⩕뼲티蝟㡸鱙酝䷈穉跰皐鸙ꢉ녷䭣컨泣哊⭎鷌隆ȭ톱浴ᎅ⍙蚴蠟䰲ꑭ䲰鉉�뛉綂琄ꚛL鸙ꗄ黏坔ぅ팆晟ꌽ骋쎆ꅃ䂍�쑯퉼⒈།蠰雭핀辫岏䳭쫱罡툏겞㱯綥ࠦ鹶흁妜遊엛﫫㰆ꝍ䄱࿅�林㑰�먒ᘛ⌈吁ຶᒅ셛䢋░塂ੇ⻵묦滏彾㤮螹昮䧫巋Ұᨧ⊱달㚘䀡닡뒵蹡堕聋裕㗶搡ᘵ휲ꥅ൩羢异貗Ᏸ㲬諙桋禜ꃄ燊煶걋୎ˢ㔦ꩤ䨟ꀋ鎧엕玜㞄兺ܨ叟ൕ殄䇀�쏤㶦㮆焤ᳶ﫴咑傖作ﶽ鏐⦪쟥⯄⦗ৠ䊗폜鿂壊缬ꢤ퇏ॽﯨ띌晉ﮬ趆⫹푡綎囿닽㲁㐮쒁﮺㗺▿팢젶→䩡﩯ᗁ쾰殇ﺎ亹㽧㴬쎜ꦏ微봙▘㕾◯뜳令휀仏鸚须룠ઠ廌焔 输出

d.base64EncodedString()

哪个不能解码为有意义的东西。确认设备受AgAAAMnpahZCKl0BcSne+W5rEZAEUNk0+me89vLfv5ZingpyOOkgXXXyjPzYTzWmWSu+BYqcD47byirLZ++3dJccpF99hWppT7G5xAuU+y56WpSYsATixT/O9/NYYwR9b949uZGYhLW8qIoW8ijCXhaq94tIE7vv5IJLV+8+UI0/Soj8MYnrAWTPvIcWYixwdctCKBqDTwgAAJDkPBNwDD76iCaCvGO8XGDVaHu/tTslBdVGAeZ0DBYyQbLxUTclU66+kHWOwBiXrTcw1/Tmn6iDA/6GPVD2HNUPHXNGe0b1YOZi4epUriLrjYn10XKE1MR9+erkksN/IftcUlRkocbiVjmLFB8V+9g7U4otZeFOU6aT2Sr7zNJuJ5zCO7VCyg5QQf0LZYQVmX8XZAXW6CzEbfUhDNkfxeAF75EhGBLx+ncO7E1w23y6ag0wyZDw5uE4q3Thn92xSYiJ+jhAVi44bAmhVNyUcspVxoyFGzf1Rpisn+sdLL7RKNhRInExCSXo1CJ9HWMAhri6lNhKa46CwlBL//Z3nketVQRs//ogH24utyUrgaCJP0SUnnWWWI4PBygyiE7aEx95Qarb1LPB6cnmpGMUXPapohJOjZr/cLi2gAXnOHOBehdPwSFrl+MpgnCprL9Jhn4iMklM2kDpTg82qkT1Lg67wB3F4j3u5GCyDxEjxbn3TOGb71KTGLLNtZHeWYwt4SrrCdpwG87N/jNvqJnTYAGJttC2QKYUi4VcNad5XJplb+ZII/HD08XNK6fG+XTc8w9SLokN+9SO8GgAW6elq8kaI2xLXu+JyHbsTmROBakDqofAG12VREC5IHnY/wD9qnQ5ELn+i9EfXQkVqkL/uVmFf7eNYhD7LxQmqsQNVVmZJVoPCqLAQViaf3AszLhfxO6nO9Oh/8KhSGXp8Ch6qRN2zmJAzXRC6QNJ9Pw4oOOUj2axWIFWFokH+6fzEFOQolINtnHPvRwVhHrg19PWCoGhd9VkdC5RoxxQMAUr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xBU4ZOOOsTlsv5Qtx4XubUnD+GyZBpGJbdZnEoRTnjnDqWgAf/86VwZFSLeokweicyqlc8w1IuMFOFjqVA20NstxxuXT+cVvR3FcXFQexDKpnV5g+sfr4Vv26kK373HUMJau+NA77jt1CjU3C9d1ECtCfCtdNfTrjHO8e59FIEOchn1ZjLcPyS9JOFRr+I6iIFktdpjP54gQzvuS6P22O1/acwyT0fnTzGIhjCAdEPciGgr3Tx359VVdU+bc8RN8IFVIzXiJhNV5lzSD+xSOnGumUhMTtjnnHhK/vsbnS8+4SAM6C7yLR8r6sqMcoLvsloyaWpORi6iooKZPE/NkHbbNoNLR/zOY1uhLl88ehxVaItWGcOG2RF/Y8MB3O764bU2BR9tTvl3vghAgrsXxy+ME+XOXE4wVFmUicSblB8SmkbScbazPIRz+LDZLQHf/rUoPwoDLvM60yQ7hsrwzeKQtgIrHWpdXyjIpFscAdy0hFLP/a0Hpzdr2f0H41gmGW9I9zvH1KOPd6nJlKbXLjNipkmIEFeYyIcbIF2Xnp85syLjZgpeywm93a8QEdki2mcd45lG4BY2i6ImdVbOpjI+HyT6zJCm7OU+QMKrIT2NsaTHDHsa7m3fSAcP0MN8GYuer2P+OBwul7NEcBM8f6RLZ2LvuWDW9WqGdrzxGqpljqSfZZTq8rXBSTqUgim2d2HVjLmhfIs58iEVZWKMpE+KoohUjwkKQsWdk2pfKLrcAcJmf+V+CJ5LEVjgG9NpvV4E2JZAosS5DnY8L+C3ocSu70uo4DdbGkcHlY5kNm5DXW37OLJHD0VqVS+QQN3lsdi8d50U4s3Oz9rOz9AZtQ2Fmc2jIwVRZore5e8KhkUgVx9dy5po8N0k7WE7QKpTUqOl6GeYNfNLBDw+zdN+gWWMHEofa9m91OK27lCUw== 支持后,数据dDCDevice.generateToken()的结果。

0 个答案:

没有答案