[C++] String vergleichen

  • Ich versuche Strings zu vergleichen, komm aber nie zum richtigen Ergebnis. Steh auf dem Schlauch. Kann doch nicht so schwer sein:

    Code
                            std::string imp("improve"), col("collection"), tvs("TV show, missing episode");
                            if (reason.compare(imp) == 0)
                                text << tr("improve");
                            else if (reason.compare(col) == 0)
                                text << tr("collection");
                            else if (reason.compare(tvs) == 0)
                                text << tr("TV show, missing episode");
                            else
                                text << reason;  // To be safe if there are more options

    Hab schon einiges probiert...

    strcmp() klappt nichtweil reason std::string ist und es eine Fehlermeldung gibt. Mit reason.c_str() baut es aber es erscheint der englische Text.

    Das kann doch nicht so schwer sein?

    :/

    Kanallogos: Picon.cz2VDR | Picons2VDR | MP-Logos
    Backupskripte:
    MV_Backup (RSync) | MV_BorgBackup (Borg)

    Skin: Skin FlatPlus  VDR-Add_MSGT

    "Es gibt keinen Grund, warum irgendjemand einen Computer in seinem Haus wollen würde."
    [Ken Olson], Präsident der Digital Equipment Corp., 1977

    VDR01 - yaVDR 0.7 (VDR 2.7.3)

    VDR 2.7.3; Gehäuse: Antec Fusion V2 Black & iMon LCD; Atric IR-Einschalter Rev. 4; Board: Intel DH77EB, Core i5-3550, GTX 1050 Ti, 8 GB RAM; DVB: 1x Digital Devices CineS2 Quad V6.5

    >Systeminfo.txt< [VDR-User #1540]

  • Ja, ich habe die .mo aus dem source dann nach /usr/share/locale/de_DE/LC_MESSAGES/vdr-skinflatplus.mo kopiert. Seltsam

    Edit: Der Fehler sitzt mal wieder direkt am Eingabegerät. Habe die Datei zwar geändert aber nicht in die Virtualbox kopiert

    :wand

    Jetzt passt es

    Kanallogos: Picon.cz2VDR | Picons2VDR | MP-Logos
    Backupskripte:
    MV_Backup (RSync) | MV_BorgBackup (Borg)

    Skin: Skin FlatPlus  VDR-Add_MSGT

    "Es gibt keinen Grund, warum irgendjemand einen Computer in seinem Haus wollen würde."
    [Ken Olson], Präsident der Digital Equipment Corp., 1977

    VDR01 - yaVDR 0.7 (VDR 2.7.3)

    VDR 2.7.3; Gehäuse: Antec Fusion V2 Black & iMon LCD; Atric IR-Einschalter Rev. 4; Board: Intel DH77EB, Core i5-3550, GTX 1050 Ti, 8 GB RAM; DVB: 1x Digital Devices CineS2 Quad V6.5

    >Systeminfo.txt< [VDR-User #1540]

  • Code
                            if (reason == "improve")
                                text << tr("improve");
                            else if (reason == "collection")
                                text << tr("collection");
                            else if (reason == "TV show, missing episode")
                                text << tr("TV show, missing episode");
                            else
                                text << reason;  // To be safe if there are more options

    std::string kannst du mit dem operator '==' vergleichen, ist einfacher.

    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler
    Display Spoiler


    to spoil
    verderben
    beschädigen
    plündern
    behindern
    berauben
    vereiteln
    rauben
    zerstören [fig.] [verderben, verunstalten]
    vergällen
    verhageln [fig.]

  • Vielen Dank für den Hinweis. Probier ich bei Gelegenheit aus. Für heute ist erst mal Schluss ;)

    Kanallogos: Picon.cz2VDR | Picons2VDR | MP-Logos
    Backupskripte:
    MV_Backup (RSync) | MV_BorgBackup (Borg)

    Skin: Skin FlatPlus  VDR-Add_MSGT

    "Es gibt keinen Grund, warum irgendjemand einen Computer in seinem Haus wollen würde."
    [Ken Olson], Präsident der Digital Equipment Corp., 1977

    VDR01 - yaVDR 0.7 (VDR 2.7.3)

    VDR 2.7.3; Gehäuse: Antec Fusion V2 Black & iMon LCD; Atric IR-Einschalter Rev. 4; Board: Intel DH77EB, Core i5-3550, GTX 1050 Ti, 8 GB RAM; DVB: 1x Digital Devices CineS2 Quad V6.5

    >Systeminfo.txt< [VDR-User #1540]

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!