Skip to content

Commit

Permalink
Improve a comment
Browse files Browse the repository at this point in the history
...
  • Loading branch information
helje5 committed Nov 25, 2024
1 parent f574838 commit b4a9e6d
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions Sources/MacroCore/Buffer/BufferHexEncoding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Macro
//
// Created by Helge Heß.
// Copyright © 2020-2023 ZeeZide GmbH. All rights reserved.
// Copyright © 2020-2024 ZeeZide GmbH. All rights reserved.
//

import NIOCore
Expand All @@ -19,19 +19,21 @@ public extension Buffer {
* Returns the data in the buffer as a hex encoded string.
*
* Example:
*
* let buffer = Buffer("Hello".utf8)
* let string = buffer.hexEncodedString()
* // "48656c6c6f"
* ```swift
* let buffer = Buffer("Hello".utf8)
* let string = buffer.hexEncodedString()
* // "48656c6c6f"
* ```
*
* Each byte is represented by two hex digits, e.g. `6c` in the example.
*
* `hex` is also recognized as a string encoding, this works as well:
* ```swift
* let buffer = Buffer("Hello".utf8)
* let string = try buffer.toString("hex")
* // "48656c6c6f"
* ```
*
* let buffer = Buffer("Hello".utf8)
* let string = try buffer.toString("hex")
* // "48656c6c6f"
*
* - Parameters:
* - uppercase: If true, the a-f hexdigits are generated in
* uppercase (ABCDEF). Defaults to false.
Expand Down Expand Up @@ -67,18 +69,18 @@ public extension Buffer {
* Appends the bytes represented by a hex encoded string to the Buffer.
*
* Example:
*
* let buffer = Buffer()
* buffer.writeHexString("48656c6c6f")
* let string = try buffer.toString()
* // "Hello"
*
* ```swift
* let buffer = Buffer()
* buffer.writeHexString("48656c6c6f")
* let string = try buffer.toString()
* // "Hello"
* ```
* `hex` is also recognized as a string encoding, this works as well:
*
* let buffer = try Buffer.from("48656c6c6f", "hex")
* let string = try buffer.toString()
* // "Hello"
*
* ```swift
* let buffer = try Buffer.from("48656c6c6f", "hex")
* let string = try buffer.toString()
* // "Hello"
* ```
* - Parameters:
* - hexString: A hex encoded string, no spaces etc allowed between the
* bytes.
Expand Down

0 comments on commit b4a9e6d

Please sign in to comment.