readtextfile

by Tim C. Lueth, SG-Lib Toolbox: SolidGeometry 5.6 - Auxiliary function
Introduced first in SolidGeometry 5.0, Creation date: 2021-02-05, Last change: 2025-09-15

simply reads an ascii text file

Description

With the introduction of UTF-16 it is getting much more complicated to handle textfile and to maintain old code. UTF-16 files start with ascii 255 and are converted by txt=txt(3:2:end)

See Also: SGgcoderead , PosereadAPD , SGreadstructfile , writetextfile

Example Illustration

 missing image of readtextfile(fname,tsize,lines,

Syntax

[TEXT,s,fname]=readtextfile([fname,tsize,lines,"UTF"])

Input Parameter

fname: file name
tsize: numer of characters to read from the file start
lines: if tsize='' the following lines are extracted
"UTF": if 'UTF-8' is used, an "UTF-16" (Matlab 2024b) is returned as UTF-8

Output Parameter

TEXT: ASCII content uin8 / char
s: separator by newlin
fname: filename

Examples


readtextfile('/Volumes/LUETH-WIN/WIN AIM Matlab Libraries/SolidGeometry-Code/PLcircle.m')
readtextfile('/Volumes/LUETH-WIN/WIN AIM Matlab Libraries/SolidGeometry-Code/PLcircle.m',100) % 100 Bytes
readtextfile('/Volumes/LUETH-WIN/WIN AIM Matlab Libraries/SolidGeometry-Code/PLcircle.m','',2:4) % Lines 2:5




Copyright 2021-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth

Last html export of this page out of FM database by TL: 2025-09-21