CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 3 of 3 FirstFirst 123
Results 31 to 45 of 45
  1. #31
    Join Date
    Aug 2019
    Posts
    56

    Re: How to convert const std::filesystem::directory_entry to tchar?

    Nice, it works. Maybe it's possible to put "Space" between?

  2. #32
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: How to convert const std::filesystem::directory_entry to tchar?

    Yes. if you want a separator, just replace ""s with "separator"s eg " "s
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  3. #33
    Join Date
    Aug 2019
    Posts
    56

    Re: How to convert const std::filesystem::directory_entry to tchar?

    Weird. Seems I tried it before but probably I did something else.
    Edited: remebered that I tried this "' '"s.
    Last edited by prako2; August 12th, 2019 at 04:00 AM.

  4. #34
    Join Date
    Aug 2019
    Posts
    56

    Re: How to convert const std::filesystem::directory_entry to tchar?

    It doesn't work on the other email. I'm getting weird symbols again and everytime I try, they are different. Do you know why it could be?

  5. #35
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to convert const std::filesystem::directory_entry to tchar?

    Quote Originally Posted by prako2 View Post
    It doesn't work on the other email. I'm getting weird symbols again and everytime I try, they are different. Do you know why it could be?
    Could you post your actual code?
    Victor Nijegorodov

  6. #36
    Join Date
    Aug 2019
    Posts
    56

    Re: How to convert const std::filesystem::directory_entry to tchar?

    const string s3 = region + " "s + regionName;
    printf("%s\n", s3.c_str());
    email.put_Subject(s3.c_str());

  7. #37
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to convert const std::filesystem::directory_entry to tchar?

    Quote Originally Posted by prako2 View Post
    const string s3 = region + " "s + regionName;
    printf("%s\n", s3.c_str());
    email.put_Subject(s3.c_str());
    Where and how are these region and regionName defined/initialized?
    Did you debug your code? are the values of these variables correct (the same that were by initialization)?

    Did you try something like
    Code:
    string s3 = region;
    s3 += " ";
    s3 += regionName;
    instead?
    Victor Nijegorodov

  8. #38
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: How to convert const std::filesystem::directory_entry to tchar?

    Code:
    region = json.stringOf("region");
    regionName = json.stringOf("regionName");
    What are the contents of region & regionName after the assignment here? Are they null-terminated c-style strings?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  9. #39
    Join Date
    Aug 2019
    Posts
    56

    Re: How to convert const std::filesystem::directory_entry to tchar?

    Instead of "Respublic of Lithuania (next pointer)78.63.209.141" I'm getting xnŪ 78.63.209.141 or ΓΈąį 78.63.209.141. It works well in Gmail but not in Yandex.

  10. #40
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: How to convert const std::filesystem::directory_entry to tchar?

    When issues arise dealing with c-style strings, It is often useful to see the actual contents of the memory used in both hex and char display. Something like this:

    Code:
    void display(const char* str)
    {
    	for (auto s = str; *s; ++s)
    		printf("%hhx ", *s);
    
    	for (auto s = str; *s; ++s)
    		printf("%c ", *s);
    
    	puts("");
    }
    
    int main()
    {
    	const char* cc1 = "my";
    	const char* cc2 = "name";
    	const string s3 = cc1 + ""s + cc2;
    
    	display(cc1);
    	display(cc2);
    	display(s3.c_str());
    
    	printf("%s\n", s3.c_str());
    
    	return 0;
    }
    which displays:

    Code:
    6d 79 m y
    6e 61 6d 65 n a m e
    6d 79 6e 61 6d 65 m y n a m e
    myname
    then if there seems to be a problem, you can see what is the underlying data.

    So in your code, I suggest before the .put_Subject():

    Code:
    display(region);
    display(regionName);
    display(s3.c_str());
    If this doesn't display as expected, then you know in which variable the error lies. if this all displays as expected, then the issue is with .putSubject().

    PS Are you compiling as Unicode or Multi Byte Character Set? If Multi Byte, what encoding are you using - ASCII, utf-8, utf-16 etc?
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  11. #41
    Join Date
    Aug 2019
    Posts
    56

    Re: How to convert const std::filesystem::directory_entry to tchar?

    I use "Not set"

  12. #42
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to convert const std::filesystem::directory_entry to tchar?

    Quote Originally Posted by prako2 View Post
    I use "Not set"
    Well, i respect your "shortness", however it would be much better if you at least mentioned on what post you respond.
    FYI: Before you post....
    Victor Nijegorodov

  13. #43
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    7,822

    Re: How to convert const std::filesystem::directory_entry to tchar?

    I suspect this is the answer to the PS in post #40, and means that the Character Set property for the project is 'Not Set'. In which case I suggest changing it to 'Multi-byte character set' - and also saying what is the output from using the display() functions as also suggested in post #40.
    All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!

    C++23 Compiler: Microsoft VS2022 (17.6.5)

  14. #44
    Join Date
    Aug 2019
    Posts
    56

    Re: How to convert const std::filesystem::directory_entry to tchar?

    VictorN, I'm sorry for being rude. 2kaud Thanks for helpful tips but I changed my code and I'm not able to test it.

  15. #45
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,396

    Re: How to convert const std::filesystem::directory_entry to tchar?

    Quote Originally Posted by prako2 View Post
    VictorN, I'm sorry for being rude. 2kaud Thanks for helpful tips but I changed my code and I'm not able to test it.
    Better late than never...
    Victor Nijegorodov

Page 3 of 3 FirstFirst 123

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured