当前位置: 首页 > news >正文

自己做网站很难一个网站的建设需要什么

自己做网站很难,一个网站的建设需要什么,网站建设行业细分,大连旧房翻新装修哪家公司好数据压缩是一个软件开发中的常见需求#xff1a;很多时候需要先将较大的数据进行压缩然后再通过网络等进行传输。在 .NET 中#xff0c;有多个压缩算法供我们选择#xff1a;Deflate、GZip 和 Br 。这些压缩算法都是基于流#xff08;Stream#xff09;的#xff0c;在对… 数据压缩是一个软件开发中的常见需求很多时候需要先将较大的数据进行压缩然后再通过网络等进行传输。在 .NET 中有多个压缩算法供我们选择Deflate、GZip 和 Br 。这些压缩算法都是基于流Stream的在对字符串压缩前需要先将其转换成字节数组。还有一个比较常见的压缩算法是lz-string 。其官方文档在这里https://pieroxy.net/blog/pages/lz-string/index.html压缩后的数据一般是流或者字节数组在压缩字符串的场景下期望的压缩结果大概率也是字符串。常见的字节数组编码方式有以下几种Base16Base62Base64Ascii85不同的压缩算法对应了不同的解压缩算法。同样的不同的编码算法也对应了不同的解码算法。为了降低使用难度可以在压缩结果中将使用的压缩算法和编码算法嵌入这样就可以使用一个解压缩方法去解压任意支持的数据。LuYao.Common基于上述考虑笔者编写了一个名为 StringZipper 的静态类用于辅助进行字符串的压缩和解压缩。该类属于 LuYao.Common 可以在 NuGet 下载https://www.nuget.org/packages/LuYao.Common/StringZipper 的成员public static class StringZipper {public interface ICompressor{string Identifier { get; }byte[] Compress(string value);string Decompress(byte[] data);}public interface IEncoder{string Identifier { get; }string Encode(byte[] data);byte[] Decode(string value);}public static IEncoder Base16 { get; }public static IEncoder Base62 { get; }public static IEncoder Base64 { get; }public static IEncoder Ascii85 { get; }public static ICompressor LzString { get; }public static ICompressor Deflate { get; }public static ICompressor GZip { get; }public static ICompressor Br { get; }private static void Register(string identifier, object component);public static void Register(ICompressor compresser);public static void Register(IEncoder encoder);public static bool TryGetComponentT(string id, out T component);public static string Zip(string str, ICompressor compressor, IEncoder encoder);public static string Zip(string str);public static string Unzip(string str); }使用 StringZipper 压缩字符串最简单的使用方式就是直接调用 StringZipper 的 Zip 方法默认情况下会使用 Deflate 压缩算法和 Ascii85 编码using LuYao; var input man is distinguished, not only by his reason, but also by this singular passion from other animals; in whom the appetite of food, and other pleasures of sense, by predominance, take away the care of knowing causes; which is a lust of the mind, that by a perseverance of delight in the continual and indefatigable generation of knowledge, exceedeth the short vehemence of any carnal pleasure.; var output StringZipper.Zip(input); Console.WriteLine(output);var bytesFrom Encoding.UTF8.GetByteCount(input); var bytesTo Encoding.UTF8.GetByteCount(output);Console.WriteLine({0} {1} {2:0.##%},bytesFrom,bytesTo,1d*bytesTo/bytesFrom);输出data:text/x-deflate;ascii85,~23?4J%VHaG6SCZ)39YnDE7!KYd9D2tfhWJ,^cgm0hTEta?GJmU_ekKWRQilMfObfMl1a$n3T;ti;VBr]sfYusqtXm8:)4amP^.pgK[(QXW5PgSMh?,H9f94YdUQrJRc-tTg9*LGZ!ctH5dj6ZJZjlBPEZuWoYDp^A-WFo#t[io.[%/8EOoq4^IBD)XDC?UB_qFZ#KNe*9ZggakM-h-*mulYKa3gp.VOTjcfPKIRVtcTCa_NYjXPN,nMuui]b;FW)!NXquZ~ 391 320 81.84%如果需要使用其他的压缩算法或编码方式Zip 方法有一个需要三个参数的重载将对应的静态属性传入即可。如果需要使用 Br 压缩和 Base64 编码则可以使用以下代码var output StringZipper.Zip(input, StringZipper.Br,StringZipper.Base62);使用 StringZipper 解压字符串与压缩时可以指定压缩和编码方式相比解压缩只有一个方法 Unzip 。该方法会自动判断传入的字符串是否被压缩以及压缩时使用的参数using LuYao; var input data:text/x-deflate;ascii85,~23?4J%VHaG6SCZ)39YnDE7!KYd9D2tfhW\J,^cgm0hTEta?GJmU_ekKWRQilMfObfMl1a$n3T;ti;VBr]sfYusqtXm8:)4amP^.pgK[(QXW5PgSMh?,H9f94YdUQrJRc-tTg9*LGZ!ctH5dj6ZJZjlBPEZuWoYDp^A-WFo#t[io.[%/8EOoq4^IBD)XDC?UB_qFZ#KNe*9ZggakM-h-*mulYKa3gp.VOTjcfPKIRVtcTCa_NYjXPN,nMuui]b;FW)!NXquZ~; var output StringZipper.Unzip(input); Console.WriteLine(output);输出man is distinguished, not only by his reason, but also by this singular passion from other animals; in whom the appetite of food, and other pleasures of sense, by predominance, take away the care of knowing causes; which is a lust of the mind, that by a perseverance of delight in the continual and indefatigable generation of knowledge, exceedeth the short vehemence of any carnal pleasure.路遥工具箱中的功能集成路遥工具箱已经内置了【文本压缩】功能在【文字处理】菜单下。其采用的压缩、解压算法与本文所采用的相同。这就代表着可以在开发或者调试时很容易对已压缩的数据进行解压提高软件开发的效率。
http://www.ihoyoo.com/news/38434.html

相关文章:

  • 怎么压缩网站广州h5设计网站公司
  • 网站建设 推广人员wordpress添加新浪微博
  • 金山网站安全检测沧州网站建设设计
  • 网站是一个链接的页面结合吗律师事务所公司类网站建设案例
  • 婚恋网站如何做推广wordpress网站特别卡
  • 做视频教学网站服务器配置微信小程序开发app
  • 搭建网站宣传哪里可以学网站建设
  • 网站开发的技术路线是什么优化防控举措
  • 北京建站公司推荐首推万维科技科技让生活更美好500字六年级
  • 做网站的工作好做吗国外网站如何建设
  • 佛山优化网站关键词哪个不是常用的网页制作工具
  • 微信平台可以做微网站吗深圳app开发红孩儿
  • 卖视频会员个人网站怎么做网站开发人才
  • 建设网站必须用dnsqq上网站做我女朋友
  • 佛山技术支持 骏域网站建设在阿里云服务器搭建wordpress
  • 徐州网站客户怎么做微信小说网站
  • 网站开发招聘简历模板做资源共享网站
  • 青岛正规网站建设哪家好汝南县网站建设
  • 网站分类代码深圳企业社保网站官网
  • 爱站网seo工具平面设计证书考证官网
  • wordpress一小时建站微信个人商城网站模板免费下载
  • 网站开发学徒工作如何wordpress数据库链接不上
  • 谷歌网站英文新干网站新干今年有哪些重大建设
  • 做纯静态网站怎么样承接app网站开发的广告
  • 电商网站用php做的吗百石网怎么做网站
  • 做影视后期有哪些资源网站网站设计实训报告
  • 新乡做网站的多吗lpl赛区战绩
  • 做网站看什么书个人网站备案费用
  • 上海市建设局网站佛山大良营销网站建设
  • 安徽网站建设网站建设详细教程视频