Viyi.Strings 1.2.5

There is a newer prerelease version of this package available.
See the version list below for details.
dotnet add package Viyi.Strings --version 1.2.5
NuGet\Install-Package Viyi.Strings -Version 1.2.5
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Viyi.Strings" Version="1.2.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Viyi.Strings --version 1.2.5
#r "nuget: Viyi.Strings, 1.2.5"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Viyi.Strings as a Cake Addin
#addin nuget:?package=Viyi.Strings&version=1.2.5

// Install Viyi.Strings as a Cake Tool
#tool nuget:?package=Viyi.Strings&version=1.2.5

Viyi.Strings

1. 关于 (About)

Viyi.Strings 是从 Viyi.Util 中分离出来的,专注于处理字符串相关内容的一个库。目前主要提供对二进制数据进行十六进制编/解码和 Base64 编/解码。将来会提供更多的字符串工具。

English [en]

Viyi.Strings is a library separated from Viyi.Util, which focuses on processing strings. At present, Viyi.Strings supplies Base64 and Hex encoding/decoding by extension methods, as well as a text encoding/decoding framework. More string tools will be available in the future.

Viyi.Strings 使用木兰宽松许可证第 2 版(Mulan Permissive Software License, Version 2)。

原 Viyi.Util 涉及的范围非常多,过于分散,而且其中部分工具已经有更好的替代品。所以没有对 Viyi.Util 直接进行升级,而是将其拆分:

  • Viyi.Strings 用于处理字符串 (Viyi.Strings is a string toolkit.)
  • Viyi.Bytes 用于处理二进制数据,计划中 (Viyi.Bytes is a binary data toolkit, in planning.)

2. 安装 (Install)

Viyi.Strings 发布在 NuGet 上,在 Visual Studio 中可以使用 [NuGet Package Manager][vs_nuget] 安装,也可以在 Powershell Manager 命令行安装:

Install-Package Viyi.Strings

或通过 .NET CLI 安装:

dotnet add package Viyi.Strings

或使用其他 NuGet 支持的方式进行安装。

3. 源代码 (Source Codes)

源代码托管在 gitee.com 上:传送门 (Follow this link to source codes)

4. 主要功能 (Main Features)

  • 基于文本的编/解码

    基于文本的编/解码主要依据 [RFC-4648 (rfc-editor.org)][rfc_4648]。

    • Base 64 编/解码:EncodeBase64()/DecodeBase64()

      • Base 64 Url 编/解码:EncodeBase64Url() / DecodeBase64Url()

      • 兼容 Base 64 和 Base 64 Url 的解码:DecodeBase64Compatible()

    • Base 16(十六进制)编/解码:EncodeBase16()/DecodeBase16()

      • 别名:EncodeHex()/DecodeHex()
    • Base 32 编/解码:EncodeBase32()/DecodeBase32()

      • Base 32 Hex 编/解码:EncodeBase32Hex() / DecodeBase32Hex()
    • Utf8 编/解码:EncodeUtf8()/DecodeUtf8()

      使用 System.Text.Encoding.UTF8 实现

    • 其他 Encoding 编/解码快捷调用扩展方法:Encode()/Decode()

    • TextCodec 管理各心及抽象化接口

  • 空字符串和空白字符串

    • IsEmpty()IsSpaces() 灵活判断
      • IsNotEmpty()IsNotSpaces()
    • EmptyAs()SpacesAs() 灵活赋予默认值
  • 命名风格转换(大小规则写转换)

    • CamelCase()/PascalCase()/KebabCase()/SnakeCase() 扩展方法
    • CaseTo(string) 扩展方法按自定义规则转换
    • CaseConvert 注册中心和 ICaseConverter 接口
  • 在整数和字符串之间进行 2~36 进制转换

    • ToString(int radix)
    • ToInt32(int radix)/ToUInt32(int radix)
    • ToInt64(int radix)/ToUInt64(int radix)
    • ToInt32(true) / ToUInt32(true) / ToInt64(true) / ToUInt64(true) 解析带 "0x" 前缀的十六进制数。
  • 解析为布尔值,灵活支持 on/offyes/no 及其他字符串内容

    • ToBoolean() 系列扩展方法
    • CreatePredicator() 工具方法创建断言函数
  • 数字范围生成/解析

    #1~10#,#25,#30~#35 这种形式的范围表示法和 int[] 之间进行转换,允许自定义分隔符、连字符和标号前缀。

    • NumsRange.Parse() / new NumsRange().Parse()
    • NumsRange.ToRangeString()

    注意:ToRangeString() 不会对数据源进行排序,若有必要请先调用 OrderBy() 扩展方法排序。

  • Human Readable Size 表示

    将整数表示的存储容量大小(字节/位)处理成对人类友好,易于识别的,带 K、M、G 等单位的格式。

    • (ulong/long/uint/int).ToReadableSize(Action<Options>? config = null)
    • 可以通过 OptionsAction<Options> 配置
      • 基本单位 Bb,或者其他
      • 计量单位 K, M, G, ... 或其他
      • 计算方式,以 10241000 作为除数
      • 总长度及小数位数
      • ……
  • 解析表示时间长度的字符串,如 5m2hours

    • string.ToTimeSpan(string defaultUnit = "m")
      • 可以解析分钟 (m/minutes)、小时 (h/hours)、秒 (s/seconds)、天 (d/days)、周 (w/weeks) 及毫秒 (ms/milliseconds) 等
      • 数值部分目前仅支持整数
  • 对 FormattableString 预先进行一次格式化处理

    在使用 ExecuteSqlInterpolated() 前可以使用 PreFormat 预先处理掉不是 SQL 参数的插值(比如表名)。

    • FormattableStringPreFormat() 扩展

5. 支持和贡献

如果您有新的想法或者发现 BUG,请在 Issue 系统中提出来,经过讨论之后确定是否添加/修改,以及如何进行。

如果您愿意贡献代码,请 Fork 本库,从 develop 分支创建功能/BUG/任务分支,根据 Issue 修改之后,向 develop 分支提起 PR。

非常感谢各位的支持和贡献!

[rfc_4648]: https://www.rfc-editor.org/rfc/inline-errata/rfc4648.html ""RFC-4648"" [argumentnullexception]: https://docs.microsoft.com/dotnet/api/system.argumentnullexception "ArgumentNullException" [argumentexception]: https://docs.microsoft.com/dotnet/api/system.argumentexception " ArgumentException" [notsupportedexception]: https://docs.microsoft.com/dotnet/api/system.notsupportedexception "NotSupportedException" [vs_nuget]: https://docs.microsoft.com/zh-cn/nuget/consume-packages/install-use-packages-visual-studio

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0-beta 67 1/16/2024
1.2.5 166 7/22/2023
1.2.4 159 4/17/2023
1.2.3 434 11/10/2022
1.2.2 370 9/30/2022
1.2.2-alpha 136 9/28/2022
1.2.1 386 9/11/2022
1.2.1-alpha.3 107 9/8/2022
1.2.1-alpha.2 96 8/24/2022
1.2.1-alpha 113 8/14/2022
1.2.0-preview-4 112 7/27/2022
1.2.0-preview-3 121 7/24/2022
1.2.0-preview-1 112 7/22/2022
1.2.0-preview 110 7/18/2022
1.1.2 405 7/3/2022
1.1.1 398 6/25/2022
1.1.0 391 6/25/2022
1.0.5 383 9/20/2021
1.0.4 294 9/6/2021
1.0.3 333 9/5/2021
1.0.2 286 8/30/2021
1.0.1 302 8/6/2021