Hello
I load a text file into a string. Then I start seraching for a substring that appears many time in the file. Once I find an occurrence of the substirng I have to find the first accurance of " before it (there has to be one). Then I copy the substring starting with the first " until the index of the substring's occurrence
I find the occurrence of the substring without any problems, and in most cases, I find the first " without any problem either. But there are some places (always the same) where once I find the occurrence of the substring and try to find the first ", it finds something completely different. I know it will sound crazy, but for some reason the search for " jumps to another part of the file for no apparent reason
I've tried to debug and access each index and at a certain index it just jumps to another location in the file
I tried to find " using String.LastInde xOf, I tried manually and I tried using StringBuilder
I also tried to view the file of a hex editor to see if there are any strange characters in it that will cause it to jump to another location in the file, but found nothing..
I also checked, and the string I get as a result of the search doesn't appear anywhere in the file
Is it a bug or am I missing something here
Thanks! 2 1567
Mike <an*******@disc ussions.microso ft.com> wrote: I load a text file into a string. Then I start seraching for a substring that appears many time in the file. Once I find an occurrence of the substirng I have to find the first accurance of " before it (there has to be one). Then I copy the substring starting with the first " until the index of the substring's occurrence. I find the occurrence of the substring without any problems, and in most cases, I find the first " without any problem either. But there are some places (always the same) where once I find the occurrence of the substring and try to find the first ", it finds something completely different. I know it will sound crazy, but for some reason the search for " jumps to another part of the file for no apparent reason! I've tried to debug and access each index and at a certain index it just jumps to another location in the file. I tried to find " using String.LastInde xOf, I tried manually and I tried using StringBuilder. I also tried to view the file of a hex editor to see if there are any strange characters in it that will cause it to jump to another location in the file, but found nothing... I also checked, and the string I get as a result of the search doesn't appear anywhere in the file!
Is it a bug or am I missing something here?
Sounds like it could well be an encoding problem, to be honest. What
encoding is the file in, and how are you reading it? If you dump the
string into a textbox, does everything look okay?
If that doesn't help, please try to come up with a short but complete
example which demonstrates the problem.
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
I found the problem. I was reading the file using a stream, and I read it into a buffer incorrectly, so I must have had illegal characters in the string while I was trying to read it
Thanks for the help! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Daniel Billingsley |
last post by:
I've got to believe this is a fairly common / classic problem, and I think
I've even read an example somewhere in my education thus far, but I sure
can't remember it.
Suppose I want to store a list of first and last names read from a file. I
think somewhere I need an ArrayList. So I have a class that stores a
private ArrayList.
I want this class to be able to return the first name, the last name, or a
"calculated" FullName... but I...
|
by: mdub317 |
last post by:
I'm totally new to programming and I am wondering; when would be a good time
to use an array or an indexer? I want to know what types of applications
would make good use of arrays or indexers. There seems to be other ways of
doing the jobs of the two and less confusing.
The books I read don't provide good examples of situations when I would need
an array or indexer. I don't really need a definition of them as I already
have that. I...
|
by: JJ |
last post by:
Hi,
I have created an Arraylist object from an Arraylist class.
I added rows to the arraylist object and I need to find a particular record
in my arraylist. How do I do this? Also if I was in the middle of building
the arraylist and wanted to call the last record added to arraylist object
how can I do this?
Thanks,
|
by: gmccallum |
last post by:
I am trying to convert the value of a string to a defined enum value such as
follows.
public enum MyEnum { One, Two };
string MyString = "One";
// or even this is fine
string MyString2 = "MyEnum.One";
// This doesn't work (obviously), but effectively this
|
by: SpotNet |
last post by:
Hello NewsGroup,
I have a custom class and a collection for that custom class that inherits
CollectionBase. As such;
public class MyClass
{
private string datamember1 = string.Empty, datamember2 = string.Empty;
private int datamember3 = -1;
| |
by: Robert W. |
last post by:
In a posting earlier this year I found a simple approach to convert a string
to a particular Enum value. The one line solution looked like this:
MyEnum ConvertedString = (MyEnum) Enum.Parse(typeof(MyEnum), MyString, true);
This is fine if one wants to hardcode each and every Enum in an If-ElseIf or
Select-Case construct but I'm wondering if there's a way to do it generically?
I have a situation where I'm using reflection to set a...
|
by: Clive Dixon |
last post by:
Is it possible to access an indexer of a base class with identical
signature, e.g.
class Class1
{
public object this
{
get
{
// ...
|
by: Ryan Liu |
last post by:
Is DataRow uses DataRow and
DataRow much efficient than DataRow?
Thanks,
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
Ryan Liu
Shanghai Fengpu Software Co. Ltd
Shanghai , China
|
by: abir |
last post by:
i have a template as shown
template<typename Sclass Indexer{};
i want to have a specialization for std::vector both const & non const
version.
template<typename T,typename Aclass Indexer<std::vector<T,A {}
matches only with nonconst version. anyway to match it for both? and
get if it is const or nonconst?
Actually i want 2 specialization, one for std::vector<T,Aconst & non
const other for std::deque<T,Aconst & non const.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |