16,022,417 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by gboost (Top 4 by date)
gboost
26-Jun-12 18:37pm
View
Does exactly what I needed, thank you very much :)
gboost
26-Jun-12 18:36pm
View
I very much appreciate the effort and material/info you've provided. Now I both have a working solution, and a good understanding of why it didn't work as expected; so I've learned a lot.
If I can accept both your very detailed/exhaustive answer and #4 (since it's a working example), I will do that.
Thank you :)
gboost
25-Jun-12 20:51pm
View
Well, this is a much more interesting reply than I imagined I'd get.
(Sorry if I don't reply to your satisfaction!)
I'd have to agree with you about it not making (much) sense.
I thought the problem would be something someone would spot just with those snippets as an 'oops, you did something wrong (languange-wise)', and didn't think more details were needed at the time. But I suppose it wouldn't have hurt to include them anyway -- and I probably should have.
Also hadn't considered the difference between the object types, which may be what the issue is altogether. (?)
To be a little more specific:
The strange character calculations really weren't my idea to start with. Another application is doing this to a configuration/settings file, I suppose to make it unreadable (e.g. in a text editor) to avoid issues with a user going in and changing things without being certain of what they're doing.
I'm actually just making a tool to tweak the settings (in a safe way), but need to be able to "decode"/"encode" the way said-app does -- which I was able to mimic in C, but obviously not C# (which I am trying to learn / adapt to)
Otherwise I probably wouldn't even want to do such a thing! :)
I posted an example of the text/characters to another answer.
I'm honestly not 100% sure if the encoding is 1252, but the results came out even worse unless I specified 1252 (which is what a text editor told me the encoding was, IF it is.)
Don't you love how certain .. I mean, confused, I am?
Anyway (again), an example is:
"normal"/decoded text (characters):
testing_one = "something"
testing_two = "100"
"encoded" text (by other app, or my C code):
‹šŒ‹–‘˜ ‘šßÂßÝŒ’š‹—–‘˜Ýß
‹šŒ‹–‘˜ ‹ˆßÂßÝÎÏÏÝ
attempt to "decode" the "encoded" text with C# code above
Æ?Æìç#_oç? = "oæ?Æëìç#"
Æ?Æìç#_Æ9o = "100"
(only some characters are "decoded" correctly -- it should show the 'normal'/decoded text as above)
I'm not sure if that helps any or not.
I am going to try to analyze what you wrote better and check out the links though, I am interested in learning more and understanding what's actually going on here. I appreciate it.
Hmm, not sure how to take that last statement about prose. In a way it could be insulting, I suppose. But maybe not! Because? (Kidding...)
gboost
25-Jun-12 19:28pm
View
This seems to work fine, except it's still not converting it as I expected. I wonder if it does have something to do with what lewax said (8 bit vs 16 bit)
For example, this "encoded" text:
‹šŒ‹–‘˜ ‘šßÂßÝŒ’š‹—–‘˜Ýß
‹šŒ‹–‘˜ ‹ˆßÂßÝÎÏÏÝ
Comes out as this (in C# -- looks like some of it converted ok):
Æ?Æìç#_oç? = "oæ?Æëìç#"
Æ?Æìç#_Æ9o = "100"
But it's supposed to be (and comes out as this with C):
testing_one = "something"
testing_two = "100"