{"id":20111954,"url":"https://github.com/mezoni/string_reader","last_synced_at":"2026-05-12T18:04:36.384Z","repository":{"id":196840335,"uuid":"697406231","full_name":"mezoni/string_reader","owner":"mezoni","description":"Implementation of random access string readers for reading data from various data sources in various encodings through a single `StringReader` interface.","archived":false,"fork":false,"pushed_at":"2023-09-27T17:00:38.000Z","size":6,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-13T05:43:38.570Z","etag":null,"topics":["dart","dart3","dartlang","file-reader","string-reader"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mezoni.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-27T17:00:30.000Z","updated_at":"2024-11-14T08:08:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"d3bec155-c245-40c8-b62c-9cc85f951b05","html_url":"https://github.com/mezoni/string_reader","commit_stats":null,"previous_names":["mezoni/string_reader"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mezoni%2Fstring_reader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mezoni%2Fstring_reader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mezoni%2Fstring_reader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mezoni%2Fstring_reader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mezoni","download_url":"https://codeload.github.com/mezoni/string_reader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241556482,"owners_count":19981874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dart","dart3","dartlang","file-reader","string-reader"],"created_at":"2024-11-13T18:18:19.968Z","updated_at":"2026-05-12T18:04:36.269Z","avatar_url":"https://github.com/mezoni.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# string_readers\n\nImplementation of random access string readers for reading data from various data sources in various encodings through a single `StringReader` interface.\n\nVersion: 0.1.0\n\n## About this software\n\nImplementation of random access string readers for reading data from various data sources in various encodings through a single `StringReader` interface.\n\nPossible application of this is the organization of access operations to data located in large files, as well as the organization of access to data from various sources through a single `StringReader` interface.\n\nThe current version includes the following implementations:\n- ByteReader\n- FileReader\n- StringReader\n- Utf8Reader\n\nThese implementations allow random read access to string input data from the following sources:\n- String data encoded in Utf-16 encoding\n- Byte data encoded in Utf-8 encoding\n- String data located in files\n\n## Example\n\nAn example of accessing data from various sources through a single `StringReader` interface.\n\n```dart\nimport 'dart:convert';\nimport 'dart:io';\n\nimport 'package:string_reader/file_reader.dart';\nimport 'package:string_reader/string_reader.dart';\nimport 'package:string_reader/utf8_reader.dart';\n\nvoid main(List\u003cString\u003e args) {\n  const source = 'Hello';\n  File? file;\n  RandomAccessFile? fp;\n  try {\n    const filename = 'example/temp.txt';\n    file = File(filename);\n    _writeToFile(file, source);\n    fp = file.openSync();\n    final result = _readUsingFileReader(fp);\n    print(result);\n  } catch (e) {\n    rethrow;\n  } finally {\n    if (fp != null) {\n      fp.closeSync();\n    }\n\n    if (file != null) {\n      if (file.existsSync()) {\n        file.deleteSync();\n      }\n    }\n  }\n\n  final stringReader = StringReader(source);\n  final result = _readUsingStringReader(stringReader);\n  print(result);\n}\n\nString _readUsingFileReader(RandomAccessFile fp) {\n  const bufferSize = 8;\n  final fileReader = FileReader(fp, bufferSize: bufferSize);\n  final utf8Reader = Utf8Reader(fileReader);\n  return _readUsingStringReader(utf8Reader);\n}\n\nString _readUsingStringReader(StringReader reader) {\n  final charCodes = \u003cint\u003e[];\n  var position = 0;\n  while (position \u003c reader.length) {\n    final char = reader.readChar(position);\n    position += reader.count;\n    charCodes.add(char);\n  }\n\n  return String.fromCharCodes(charCodes);\n}\n\nvoid _writeToFile(File file, String string) {\n  if (file.existsSync()) {\n    file.deleteSync();\n  }\n\n  final bytes = Utf8Encoder().convert('Hello');\n  file.writeAsBytesSync(bytes);\n}\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmezoni%2Fstring_reader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmezoni%2Fstring_reader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmezoni%2Fstring_reader/lists"}